20
20
data_path = pathlib .Path (__file__ ).parent / "data"
21
21
22
22
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
+ ):
24
26
"""Create an S3 resource in CKAN"""
25
27
if resource_path is None :
26
28
resource_path = data_path / "calibration_beads_47.rtdc"
@@ -34,7 +36,9 @@ def setup_s3_resource_on_ckan(private=False, resource_path=None):
34
36
}])
35
37
36
38
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 }
38
42
39
43
# Upload the resource to S3 (note that it is not required that the
40
44
# dataset exists)
@@ -171,8 +175,13 @@ def test_get_s3_handle(enqueue_job_mock):
171
175
@pytest .mark .usefixtures ('clean_db' , 'with_request_context' )
172
176
@mock .patch ('ckan.plugins.toolkit.enqueue_job' ,
173
177
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" ]
176
185
expected_path = s3cc .get_s3_url_for_artifact (rid , artifact = "condensed" )
177
186
with s3cc .get_s3_dc_handle (rid , artifact = "condensed" ) as ds :
178
187
assert ds .path == expected_path
@@ -228,7 +237,7 @@ def test_get_s3_dc_handle_basin_based_public_urls(enqueue_job_mock, tmp_path):
228
237
229
238
with s3cc .get_s3_dc_handle_basin_based (rid ) as ds :
230
239
# get the basins
231
- for bn_dict in ds .basins_get_dicts :
240
+ for bn_dict in ds .basins_get_dicts () :
232
241
assert not bn_dict ["perishable" ]
233
242
for url in bn_dict ["urls" ]:
234
243
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):
252
261
253
262
with s3cc .get_s3_dc_handle_basin_based (rid ) as ds :
254
263
# get the basins
255
- for bn_dict in ds .basins_get_dicts :
264
+ for bn_dict in ds .basins_get_dicts () :
256
265
assert bn_dict ["perishable" ]
257
266
for url in bn_dict ["urls" ]:
258
267
assert url .lower ().count ("expires" )
0 commit comments