|
21 | 21 | from test import reset_tweak_changes, TEST_DIR |
22 | 22 |
|
23 | 23 |
|
| 24 | +def get_uploaded_file_names(path: str): |
| 25 | + files = [] |
| 26 | + for entry in os.scandir(path=path): |
| 27 | + if entry.is_file(): |
| 28 | + files.append(entry.name) |
| 29 | + if entry.is_dir(): |
| 30 | + nested_files = get_uploaded_file_names(entry.path) |
| 31 | + for file in nested_files: |
| 32 | + files.append('{}/{}'.format(entry.name, file)) |
| 33 | + return files |
| 34 | + |
| 35 | + |
24 | 36 | class TestDssApi(unittest.TestCase): |
25 | 37 | staging_bucket = "org-humancellatlas-dss-cli-test" |
26 | 38 |
|
27 | 39 | @classmethod |
28 | 40 | def setUpClass(cls): |
29 | | - cls.client = hca.dss.DSSClient() |
| 41 | + cls.client = hca.dss.DSSClient(swagger_url="https://dss.dev.data.humancellatlas.org/v1/swagger.json") |
30 | 42 |
|
31 | 43 | def test_set_host(self): |
32 | 44 | with tempfile.TemporaryDirectory() as home: |
@@ -73,7 +85,7 @@ def test_python_nested_bundle_upload_download(self): |
73 | 85 |
|
74 | 86 | def test_python_upload_download(self): |
75 | 87 | bundle_path = os.path.join(TEST_DIR, "res", "bundle") |
76 | | - uploaded_files = set(os.listdir(bundle_path)) |
| 88 | + uploaded_files = set(get_uploaded_file_names(bundle_path)) |
77 | 89 |
|
78 | 90 | manifest = self.client.upload(src_dir=bundle_path, |
79 | 91 | replica="aws", |
@@ -139,7 +151,7 @@ def test_python_upload_download(self): |
139 | 151 |
|
140 | 152 | def test_python_manifest_download(self): |
141 | 153 | bundle_path = os.path.join(TEST_DIR, "res", "bundle") |
142 | | - uploaded_files = set(os.listdir(bundle_path)) |
| 154 | + uploaded_files = set(get_uploaded_file_names(bundle_path)) |
143 | 155 |
|
144 | 156 | manifest = self.client.upload(src_dir=bundle_path, |
145 | 157 | replica="aws", |
@@ -222,9 +234,14 @@ def test_python_bindings(self): |
222 | 234 | bundle_path = os.path.join(TEST_DIR, "res", "bundle") |
223 | 235 | bundle_output = self.client.upload(src_dir=bundle_path, replica="aws", staging_bucket=self.staging_bucket) |
224 | 236 | bundle_uuid = bundle_output['bundle_uuid'] |
| 237 | + bundle_version = bundle_output['version'] |
| 238 | + bundle_fqid = "{}.{}".format(bundle_uuid, bundle_version) |
225 | 239 |
|
226 | 240 | with tempfile.TemporaryDirectory() as dest_dir: |
227 | 241 | self.client.download(bundle_uuid=bundle_output['bundle_uuid'], replica="aws", download_dir=dest_dir) |
| 242 | + nested_downloaded_files = [file.name for file in os.scandir('{}/{}/zarr'.format(dest_dir, bundle_fqid))] |
| 243 | + for file in ['exclamation.zattrs', 'nested.zattrs']: |
| 244 | + self.assertIn(file, nested_downloaded_files) |
228 | 245 |
|
229 | 246 | # Test get-files and head-files |
230 | 247 | file_ = bundle_output['files'][0] |
|
0 commit comments