Skip to content

Commit

Permalink
fix start computation test
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Mar 21, 2023
1 parent 74ad873 commit 2c4df34
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion services/osparc-gateway-server/tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2c4df34

Please sign in to comment.