Skip to content

Commit 3c52ce2

Browse files
committed
add tests for new implementations
1 parent 386e899 commit 3c52ce2

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed

packages/pytest-simcore/src/pytest_simcore/helpers/catalog_rpc_server.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
from pydantic import NonNegativeInt, TypeAdapter
2929
from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient
3030

31+
assert ServiceListFilters.model_json_schema()["properties"].keys() == {
32+
"service_type"
33+
}, (
34+
"ServiceListFilters is expected to only have the key 'service_type'. "
35+
"Please update the mock if the schema changes."
36+
)
37+
3138

3239
class CatalogRpcSideEffects:
3340
# pylint: disable=no-self-use
@@ -44,11 +51,15 @@ async def list_services_paginated(
4451
assert rpc_client
4552
assert product_name
4653
assert user_id
47-
assert filters is None, "filters not mocked yet"
4854

4955
items = TypeAdapter(list[LatestServiceGet]).validate_python(
5056
LatestServiceGet.model_json_schema()["examples"],
5157
)
58+
if filters:
59+
items = [
60+
item for item in items if item.service_type == filters.service_type
61+
]
62+
5263
total_count = len(items)
5364

5465
return PageRpc[LatestServiceGet].create(

services/api-server/src/simcore_service_api_server/api/routes/solvers.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,36 @@ async def list_solvers_releases(
146146
page_params.total_number_of_items = page_meta.total
147147
latest_releases.extend(services)
148148

149-
all_releases = []
150-
for service in latest_releases:
149+
all_solvers = []
150+
for service_release in latest_releases:
151151
for page_params in iter_pagination_params(limit=DEFAULT_PAGINATION_LIMIT):
152152
services, page_meta = await catalog_service.list_release_history(
153153
product_name=product_name,
154154
user_id=user_id,
155-
service_key=service.id,
155+
service_key=service_release.key,
156156
offset=page_params.offset,
157157
limit=page_params.limit,
158158
)
159159
page_params.total_number_of_items = page_meta.total
160-
all_releases.extend(services)
161-
162-
solvers = [Solver.create_from_service(service) for service in all_releases]
160+
all_solvers.extend(
161+
[
162+
Solver.create_from_service_release(
163+
service_key=service_release.key,
164+
description=service_release.description,
165+
contact=service_release.contact,
166+
name=service_release.name,
167+
service=service,
168+
)
169+
for service in services
170+
]
171+
)
163172

164-
for solver in solvers:
173+
for solver in all_solvers:
165174
solver.url = url_for(
166175
"get_solver_release", solver_key=solver.id, version=solver.version
167176
)
168177

169-
return sorted(solvers, key=attrgetter("id", "pep404_version"))
178+
return sorted(all_solvers, key=attrgetter("id", "pep404_version"))
170179

171180

172181
@router.get(

services/api-server/tests/unit/api_solvers/test_api_routers_solvers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,21 @@ async def test_list_solver_ports(
8989
},
9090
],
9191
}
92+
93+
94+
async def test_list_solvers_with_mocked_catalog(
95+
client: httpx.AsyncClient,
96+
mocked_rpc_catalog_service_api: dict,
97+
auth: httpx.BasicAuth,
98+
):
99+
response = await client.get(f"/{API_VTAG}/solvers", auth=auth)
100+
assert response.status_code == status.HTTP_200_OK
101+
102+
103+
async def test_list_solver_releases_with_mocked_catalog(
104+
client: httpx.AsyncClient,
105+
mocked_rpc_catalog_service_api: dict,
106+
auth: httpx.BasicAuth,
107+
):
108+
response = await client.get(f"/{API_VTAG}/solvers/releases", auth=auth)
109+
assert response.status_code == status.HTTP_200_OK

0 commit comments

Comments
 (0)