From 2c4df34f5d6f910eca37b64d0887fe99e1fabb72 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Tue, 21 Mar 2023 09:28:25 +0100 Subject: [PATCH] fix start computation test --- .../with_dbs/test_api_route_computations.py | 23 ++++++++++++++++++- .../tests/unit/test_utils.py | 5 +++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/services/director-v2/tests/unit/with_dbs/test_api_route_computations.py b/services/director-v2/tests/unit/with_dbs/test_api_route_computations.py index 5c65384fb774..44a4a9d26018 100644 --- a/services/director-v2/tests/unit/with_dbs/test_api_route_computations.py +++ b/services/director-v2/tests/unit/with_dbs/test_api_route_computations.py @@ -22,6 +22,10 @@ from models_library.projects_pipeline import PipelineDetails from models_library.projects_state import RunningState from models_library.services import ServiceDockerData +from models_library.services_resources import ( + ServiceResourcesDict, + ServiceResourcesDictHelpers, +) from models_library.utils.fastapi_encoders import jsonable_encoder from pydantic import AnyHttpUrl, parse_obj_as from pytest_mock.plugin import MockerFixture @@ -89,6 +93,15 @@ def fake_service_extras() -> ServiceExtras: return random_extras +@pytest.fixture +def fake_service_resources() -> ServiceResourcesDict: + service_resources = parse_obj_as( + ServiceResourcesDict, + ServiceResourcesDictHelpers.Config.schema_extra["examples"][0], + ) + return service_resources + + @pytest.fixture def mocked_director_service_fcts( minimal_app: FastAPI, @@ -123,6 +136,7 @@ def mocked_catalog_service_fcts( minimal_app: FastAPI, fake_service_details: ServiceDockerData, fake_service_extras: ServiceExtras, + fake_service_resources: ServiceResourcesDict, ): # pylint: disable=not-context-manager with respx.mock( @@ -132,7 +146,14 @@ def mocked_catalog_service_fcts( ) as respx_mock: respx_mock.get( re.compile( - r"services/(simcore)%2F(services)%2F(comp|dynamic|frontend)%2F.+/(.+)" + r"services/(simcore)%2F(services)%2F(comp|dynamic|frontend)%2F[^/]+/[^\.]+.[^\.]+.[^\/]+/resources" + ), + name="get_service_resources", + ).respond(json=jsonable_encoder(fake_service_resources, by_alias=True)) + + respx_mock.get( + re.compile( + r"services/(simcore)%2F(services)%2F(comp|dynamic|frontend)%2F[^/]+/[^\.]+.[^\.]+.[^\/]+" ), name="get_service", ).respond(json=fake_service_details.dict(by_alias=True)) diff --git a/services/osparc-gateway-server/tests/unit/test_utils.py b/services/osparc-gateway-server/tests/unit/test_utils.py index b1b17faf443b..c8f4b2e77c8c 100644 --- a/services/osparc-gateway-server/tests/unit/test_utils.py +++ b/services/osparc-gateway-server/tests/unit/test_utils.py @@ -51,7 +51,10 @@ async def create_docker_service( async def _creator(labels: dict[str, str]) -> dict[str, Any]: service = await async_docker_client.services.create( task_template={ - "ContainerSpec": {"Image": "busybox", "Command": ["sleep", "10000"]} + "ContainerSpec": { + "Image": "busybox:latest", + "Command": ["sleep", "10000"], + } }, name=faker.pystr(), labels=labels,