Skip to content

Commit 3cf118e

Browse files
committed
ongoing
1 parent a18ef42 commit 3cf118e

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

packages/pytest-simcore/src/pytest_simcore/simcore_storage_datcore_adapter.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
from collections.abc import Iterator
33

4+
import httpx
45
import pytest
56
import respx
67
from faker import Faker
@@ -25,11 +26,7 @@ def datcore_adapter_service_mock(faker: Faker) -> Iterator[respx.MockRouter]:
2526
# NOTE: passthrough the locahost and the local ip
2627
respx_mocker.route(host="127.0.0.1").pass_through()
2728
respx_mocker.route(host=get_localhost_ip()).pass_through()
28-
respx_mocker.get(
29-
"/",
30-
name="healthcheck",
31-
).respond(status.HTTP_200_OK, json={"message": "ok"})
32-
respx_mocker.get("", name="base_endpoint").respond(status.HTTP_200_OK, json={})
29+
3330
respx_mocker.get("/user/profile", name="get_user_profile").respond(
3431
status.HTTP_200_OK, json=faker.pydict(allowed_types=(str,))
3532
)
@@ -41,4 +38,22 @@ def datcore_adapter_service_mock(faker: Faker) -> Iterator[respx.MockRouter]:
4138
),
4239
)
4340

41+
def _create_download_link(request, file_id):
42+
return httpx.Response(
43+
status.HTTP_404_NOT_FOUND,
44+
json={"error": f"{file_id} not found!"},
45+
)
46+
47+
respx_mocker.get(
48+
re.compile(r"/files/(?P<file_id>[^/]+)"), name="get_file_dowload_link"
49+
).mock(side_effect=_create_download_link)
50+
51+
respx_mocker.get(
52+
"/",
53+
name="healthcheck",
54+
).respond(status.HTTP_200_OK, json={"message": "ok"})
55+
respx_mocker.get("", name="base_endpoint").respond(
56+
status.HTTP_200_OK, json={"message": "root entrypoint"}
57+
)
58+
4459
yield respx_mocker

services/storage/src/simcore_service_storage/modules/datcore_adapter/datcore_adapter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from models_library.api_schemas_datcore_adapter.datasets import (
1111
FileMetaData as DatCoreFileMetaData,
1212
)
13-
from models_library.api_schemas_datcore_adapter.datasets import PackageMetaData
13+
from models_library.api_schemas_datcore_adapter.datasets import (
14+
PackageMetaData,
15+
)
1416
from models_library.api_schemas_storage.storage_schemas import (
1517
DatCoreCollectionName,
1618
DatCoreDatasetName,

services/storage/tests/unit/test_handlers_files.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ class SingleLinkParam:
110110
expected_chunk_size: ByteSize
111111

112112

113+
@pytest.mark.parametrize(
114+
"location_id",
115+
[SimcoreS3DataManager.get_location_id()],
116+
ids=[SimcoreS3DataManager.get_location_name()],
117+
indirect=True,
118+
)
113119
@pytest.mark.parametrize(
114120
"single_link_param",
115121
[
@@ -239,6 +245,12 @@ async def _link_creator(file_id: SimcoreS3FileID, **query_kwargs) -> PresignedLi
239245
await asyncio.gather(*clean_tasks)
240246

241247

248+
@pytest.mark.parametrize(
249+
"location_id",
250+
[SimcoreS3DataManager.get_location_id()],
251+
ids=[SimcoreS3DataManager.get_location_name()],
252+
indirect=True,
253+
)
242254
@pytest.mark.parametrize(
243255
"single_link_param",
244256
[
@@ -320,6 +332,12 @@ class MultiPartParam:
320332
expected_chunk_size: ByteSize
321333

322334

335+
@pytest.mark.parametrize(
336+
"location_id",
337+
[SimcoreS3DataManager.get_location_id()],
338+
ids=[SimcoreS3DataManager.get_location_name()],
339+
indirect=True,
340+
)
323341
@pytest.mark.parametrize(
324342
"test_param",
325343
[
@@ -418,6 +436,12 @@ async def test_create_upload_file_presigned_with_file_size_returns_multipart_lin
418436
)
419437

420438

439+
@pytest.mark.parametrize(
440+
"location_id",
441+
[SimcoreS3DataManager.get_location_id()],
442+
ids=[SimcoreS3DataManager.get_location_name()],
443+
indirect=True,
444+
)
421445
@pytest.mark.parametrize(
422446
"link_type, file_size",
423447
[
@@ -482,6 +506,12 @@ async def test_delete_unuploaded_file_correctly_cleans_up_db_and_s3(
482506
)
483507

484508

509+
@pytest.mark.parametrize(
510+
"location_id",
511+
[SimcoreS3DataManager.get_location_id()],
512+
ids=[SimcoreS3DataManager.get_location_name()],
513+
indirect=True,
514+
)
485515
@pytest.mark.parametrize(
486516
"link_type, file_size",
487517
[
@@ -568,6 +598,12 @@ def complex_file_name(faker: Faker) -> str:
568598
return f"subfolder_1/sub_folder 2/some file name with spaces and special characters -_ü!öäàé+|}} {{3245_{faker.file_name()}"
569599

570600

601+
@pytest.mark.parametrize(
602+
"location_id",
603+
[SimcoreS3DataManager.get_location_id()],
604+
ids=[SimcoreS3DataManager.get_location_name()],
605+
indirect=True,
606+
)
571607
@pytest.mark.parametrize(
572608
"file_size",
573609
[
@@ -695,6 +731,12 @@ async def test_upload_real_file_with_emulated_storage_restart_after_completion_w
695731
assert s3_metadata.e_tag == completion_etag
696732

697733

734+
@pytest.mark.parametrize(
735+
"location_id",
736+
[SimcoreS3DataManager.get_location_id()],
737+
ids=[SimcoreS3DataManager.get_location_name()],
738+
indirect=True,
739+
)
698740
async def test_upload_of_single_presigned_link_lazily_update_database_on_get(
699741
sqlalchemy_async_engine: AsyncEngine,
700742
storage_s3_client: SimcoreS3API,
@@ -738,6 +780,12 @@ async def test_upload_of_single_presigned_link_lazily_update_database_on_get(
738780
assert received_fmd.entity_tag == upload_e_tag
739781

740782

783+
@pytest.mark.parametrize(
784+
"location_id",
785+
[SimcoreS3DataManager.get_location_id()],
786+
ids=[SimcoreS3DataManager.get_location_name()],
787+
indirect=True,
788+
)
741789
async def test_upload_real_file_with_s3_client(
742790
sqlalchemy_async_engine: AsyncEngine,
743791
storage_s3_client: SimcoreS3API,
@@ -949,6 +997,7 @@ async def test_download_file_no_file_was_uploaded(
949997
user_id: UserID,
950998
storage_s3_client: SimcoreS3API,
951999
storage_s3_bucket: S3BucketName,
1000+
fake_datcore_tokens: tuple[str, str],
9521001
):
9531002
missing_file = TypeAdapter(SimcoreS3FileID).validate_python(
9541003
f"{project_id}/{node_id}/missing.file"

0 commit comments

Comments
 (0)