Skip to content

Commit cd0d903

Browse files
committed
tests: fix tests
1 parent 8a41acc commit cd0d903

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/test_s3cc.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
data_path = pathlib.Path(__file__).parent / "data"
2121

2222

23-
def setup_s3_resource_on_ckan(private=False, resource_path=None):
23+
def setup_s3_resource_on_ckan(private: bool = False,
24+
resource_path: str | pathlib.Path = None
25+
):
2426
"""Create an S3 resource in CKAN"""
2527
if resource_path is None:
2628
resource_path = data_path / "calibration_beads_47.rtdc"
@@ -34,7 +36,9 @@ def setup_s3_resource_on_ckan(private=False, resource_path=None):
3436
}])
3537

3638
test_context = {'ignore_auth': False,
37-
'user': user['name'], 'model': model, 'api_version': 3}
39+
'user': user['name'],
40+
'model': model,
41+
'api_version': 3}
3842

3943
# Upload the resource to S3 (note that it is not required that the
4044
# dataset exists)
@@ -171,8 +175,13 @@ def test_get_s3_handle(enqueue_job_mock):
171175
@pytest.mark.usefixtures('clean_db', 'with_request_context')
172176
@mock.patch('ckan.plugins.toolkit.enqueue_job',
173177
side_effect=synchronous_enqueue_job)
174-
def test_get_s3_handle_condensed(enqueue_job_mock):
175-
rid, _, _, _ = setup_s3_resource_on_ckan()
178+
def test_get_s3_handle_condensed(enqueue_job_mock, tmp_path):
179+
resource_path = tmp_path / "data.rtdc"
180+
shutil.copy2(data_path / "calibration_beads_47.rtdc", resource_path)
181+
_, res_dict = make_dataset_via_s3(
182+
resource_path=resource_path,
183+
activate=True)
184+
rid = res_dict["id"]
176185
expected_path = s3cc.get_s3_url_for_artifact(rid, artifact="condensed")
177186
with s3cc.get_s3_dc_handle(rid, artifact="condensed") as ds:
178187
assert ds.path == expected_path
@@ -228,7 +237,7 @@ def test_get_s3_dc_handle_basin_based_public_urls(enqueue_job_mock, tmp_path):
228237

229238
with s3cc.get_s3_dc_handle_basin_based(rid) as ds:
230239
# get the basins
231-
for bn_dict in ds.basins_get_dicts:
240+
for bn_dict in ds.basins_get_dicts():
232241
assert not bn_dict["perishable"]
233242
for url in bn_dict["urls"]:
234243
assert not url.lower().count("expires")
@@ -252,7 +261,7 @@ def test_get_s3_dc_handle_basin_based_private_urls(enqueue_job_mock, tmp_path):
252261

253262
with s3cc.get_s3_dc_handle_basin_based(rid) as ds:
254263
# get the basins
255-
for bn_dict in ds.basins_get_dicts:
264+
for bn_dict in ds.basins_get_dicts():
256265
assert bn_dict["perishable"]
257266
for url in bn_dict["urls"]:
258267
assert url.lower().count("expires")

0 commit comments

Comments
 (0)