diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index c36c15f..721d88b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -12,10 +12,12 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: matrix: python-version: [3.7] + platform: [ubuntu-latest] + + runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 5104854..e7dc507 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,8 @@ docs-serve: .PHONY: test test: - pytest -n 8 tests + pytest -n 4 tests .PHONY: test-cov test-cov: - pytest -n 8 --cov=hsclient --cov-report html + pytest -n 4 --cov=hsclient --cov-report html diff --git a/hsclient/hydroshare.py b/hsclient/hydroshare.py index d00c55c..6ab46c4 100644 --- a/hsclient/hydroshare.py +++ b/hsclient/hydroshare.py @@ -5,7 +5,7 @@ import tempfile import time from datetime import datetime -from posixpath import basename, dirname, join as urljoin, splitext +from posixpath import join as urljoin, splitext, basename, dirname from typing import Dict, List, Union from urllib.parse import urlparse, quote, unquote from zipfile import ZipFile @@ -578,7 +578,7 @@ def file_upload(self, *files: str, destination_path: str = "") -> None: zipped_file = os.path.join(tmpdir, 'files.zip') with ZipFile(zipped_file, 'w') as zipped: for file in files: - zipped.write(file, basename(file)) + zipped.write(file, os.path.basename(file)) self._upload(zipped_file, destination_path=destination_path) unzip_path = urljoin( self._hsapi_path, "functions", "unzip", "data", "contents", destination_path, 'files.zip' diff --git a/setup.py b/setup.py index d914c4e..68f1c2e 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='hsclient', - version='0.1.6', + version='0.1.7', packages=find_packages(include=['hsclient', 'hsclient.*'], exclude=("tests",)), install_requires=[ diff --git a/tests/data/another.txt b/tests/data/another.txt new file mode 100644 index 0000000..65763bf --- /dev/null +++ b/tests/data/another.txt @@ -0,0 +1 @@ +another hello dude \ No newline at end of file diff --git a/tests/test_functional.py b/tests/test_functional.py index 349f217..d4df802 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -47,10 +47,26 @@ def timeseries_resource(new_resource): "ODM2_Multi_Site_One_Variable_meta.xml", ] root_path = "data/test_resource_metadata_files/" - new_resource.file_upload(*[root_path + file for file in files]) + new_resource.file_upload(*[os.path.join(root_path, file) for file in files]) return new_resource +def test_absolute_path_multiple_file_upload(new_resource): + files = [ + "other.txt", + "another.txt", + ] + root_path = "data" + new_resource.file_upload(*[os.path.abspath(os.path.join(root_path, file)) for file in files]) + assert len(new_resource.files()) == 2 + + +def test_absolute_path_single_file_upload(new_resource): + rel_path = os.path.join("data", "other.txt") + new_resource.file_upload(os.path.abspath(rel_path)) + assert len(new_resource.files()) == 1 + + def test_filtering_aggregations(timeseries_resource): assert len(timeseries_resource.aggregations(type=AggregationType.TimeSeriesAggregation)) == 1 timeseries = timeseries_resource.aggregation(type=AggregationType.TimeSeriesAggregation) @@ -387,7 +403,7 @@ def test_user_info(hydroshare): def test_aggregations(new_resource, files): root_path = "data/test_resource_metadata_files/" file_count = len(files) - 2 # exclude rdf/xml file - new_resource.file_upload(*[root_path + file for file in files]) + new_resource.file_upload(*[os.path.join(root_path, file) for file in files]) assert len(new_resource.aggregations()) == 1 assert len(new_resource.files()) == 0 agg = new_resource.aggregations()[0] @@ -425,7 +441,7 @@ def test_aggregation_fileset(new_resource, files): root_path = "data/test_resource_metadata_files/" file_count = len(files) - 2 # exclude rdf/xml file new_resource.folder_create("asdf") - new_resource.file_upload(*[root_path + file for file in files], destination_path="asdf") + new_resource.file_upload(*[os.path.join(root_path, file) for file in files], destination_path="asdf") assert len(new_resource.aggregations()) == 1 assert len(new_resource.files()) == 0 agg = new_resource.aggregations()[0]