|
6 | 6 |
|
7 | 7 |
|
8 | 8 | import httpx |
9 | | -import pytest |
10 | | -import simcore_service_api_server.api.routes.solvers |
| 9 | +from api_solvers.conftest import solver_version |
11 | 10 | from pydantic import TypeAdapter |
12 | | -from pytest_mock import MockFixture |
| 11 | +from pytest_mock import MockType |
13 | 12 | from simcore_service_api_server._meta import API_VTAG |
14 | 13 | from simcore_service_api_server.models.pagination import OnePage |
15 | 14 | from simcore_service_api_server.models.schemas.solvers import Solver, SolverPort |
16 | 15 | from starlette import status |
17 | 16 |
|
18 | 17 |
|
19 | | -@pytest.mark.skip(reason="Still under development. Currently using fake implementation") |
20 | | -async def test_list_solvers( |
| 18 | +async def test_list_all_solvers( |
| 19 | + mocked_catalog_rpc_api: dict[str, MockType], |
21 | 20 | client: httpx.AsyncClient, |
22 | | - mocker: MockFixture, |
| 21 | + auth: httpx.BasicAuth, |
23 | 22 | ): |
24 | | - warn = mocker.patch.object( |
25 | | - simcore_service_api_server.api.routes.solvers._logger, "warning" |
26 | | - ) |
| 23 | + response = await client.get(f"/{API_VTAG}/solvers", auth=auth) |
| 24 | + assert response.status_code == status.HTTP_200_OK |
27 | 25 |
|
28 | | - # list solvers latest releases |
29 | | - resp = await client.get("/v0/solvers") |
30 | | - assert resp.status_code == status.HTTP_200_OK |
31 | 26 |
|
32 | | - # No warnings for ValidationError with the fixture |
33 | | - assert ( |
34 | | - not warn.called |
35 | | - ), f"No warnings expected in this fixture, got {warn.call_args!s}" |
| 27 | +async def test_list_all_solvers_paginated( |
| 28 | + mocked_catalog_rpc_api: dict[str, MockType], |
| 29 | + client: httpx.AsyncClient, |
| 30 | + auth: httpx.BasicAuth, |
| 31 | +): |
| 32 | + response = await client.get(f"/{API_VTAG}/solvers/page", auth=auth) |
| 33 | + assert response.status_code == status.HTTP_200_OK |
| 34 | + assert len(response.json()["items"]) == response.json()["total"] |
36 | 35 |
|
37 | | - data = resp.json() |
38 | | - assert len(data) == 2 |
39 | 36 |
|
40 | | - for item in data: |
41 | | - solver = Solver(**item) |
42 | | - print(solver.model_dump_json(indent=1, exclude_unset=True)) |
| 37 | +async def test_list_all_solvers_releases( |
| 38 | + mocked_catalog_rpc_api: dict[str, MockType], |
| 39 | + client: httpx.AsyncClient, |
| 40 | + auth: httpx.BasicAuth, |
| 41 | +): |
| 42 | + response = await client.get(f"/{API_VTAG}/solvers/releases", auth=auth) |
| 43 | + assert response.status_code == status.HTTP_200_OK |
43 | 44 |
|
44 | | - # use link to get the same solver |
45 | | - assert solver.url |
46 | | - assert solver.url.host == "api.testserver.io" # cli.base_url |
47 | | - assert solver.url.path |
48 | 45 |
|
49 | | - # get_solver_latest_version_by_name |
50 | | - resp0 = await client.get(solver.url.path) |
51 | | - assert resp0.status_code == status.HTTP_501_NOT_IMPLEMENTED |
52 | | - assert f"GET solver {solver.id}" in resp0.json()["errors"][0] |
53 | | - # get_solver |
54 | | - resp1 = await client.get(f"/v0/solvers/{solver.id}") |
55 | | - assert resp1.status_code == status.HTTP_501_NOT_IMPLEMENTED |
56 | | - assert f"GET solver {solver.id}" in resp1.json()["errors"][0] |
| 46 | +async def test_list_all_solvers_releases_paginated( |
| 47 | + mocked_catalog_rpc_api: dict[str, MockType], |
| 48 | + client: httpx.AsyncClient, |
| 49 | + auth: httpx.BasicAuth, |
| 50 | +): |
| 51 | + solver_key = "simcore/services/comp/itis/sleeper" |
| 52 | + response = await client.get( |
| 53 | + f"/{API_VTAG}/solvers/{solver_key}/releases/page", auth=auth |
| 54 | + ) |
| 55 | + assert response.status_code == status.HTTP_200_OK |
| 56 | + assert len(response.json()["items"]) == response.json()["total"] |
| 57 | + |
| 58 | + |
| 59 | +async def test_list_solver_releases( |
| 60 | + mocked_catalog_rpc_api: dict[str, MockType], |
| 61 | + client: httpx.AsyncClient, |
| 62 | + auth: httpx.BasicAuth, |
| 63 | +): |
| 64 | + solver_key = "simcore/services/comp/itis/sleeper" |
| 65 | + response = await client.get(f"/{API_VTAG}/solvers/{solver_key}/releases", auth=auth) |
| 66 | + assert response.status_code == status.HTTP_200_OK |
| 67 | + |
57 | 68 |
|
58 | | - # get_solver_latest_version_by_name |
59 | | - resp2 = await client.get(f"/v0/solvers/{solver.id}/latest") |
| 69 | +async def test_get_solver_release( |
| 70 | + mocked_catalog_rpc_api: dict[str, MockType], |
| 71 | + client: httpx.AsyncClient, |
| 72 | + auth: httpx.BasicAuth, |
| 73 | +): |
| 74 | + solver_key = "simcore/services/comp/itis/sleeper" |
| 75 | + solver_version = "2.2.1" |
| 76 | + response = await client.get( |
| 77 | + f"/{API_VTAG}/solvers/{solver_key}/releases/{solver_version}", auth=auth |
| 78 | + ) |
| 79 | + assert response.status_code == status.HTTP_200_OK |
60 | 80 |
|
61 | | - assert resp2.status_code == status.HTTP_501_NOT_IMPLEMENTED |
62 | | - assert f"GET latest {solver.id}" in resp2.json()["errors"][0] |
| 81 | + solver = Solver.model_validate(response.json()) |
| 82 | + assert solver.version_display == "2 Xtreme" |
63 | 83 |
|
64 | 84 |
|
65 | 85 | async def test_list_solver_ports( |
66 | | - mocked_catalog_rpc_api: dict, |
| 86 | + mocked_catalog_rpc_api: dict[str, MockType], |
67 | 87 | client: httpx.AsyncClient, |
68 | 88 | auth: httpx.BasicAuth, |
69 | 89 | ): |
@@ -100,60 +120,9 @@ async def test_list_solver_ports( |
100 | 120 | } |
101 | 121 |
|
102 | 122 |
|
103 | | -async def test_list_solvers_with_mocked_catalog( |
104 | | - client: httpx.AsyncClient, |
105 | | - mocked_catalog_rpc_api: dict, |
106 | | - auth: httpx.BasicAuth, |
107 | | -): |
108 | | - response = await client.get(f"/{API_VTAG}/solvers", auth=auth) |
109 | | - assert response.status_code == status.HTTP_200_OK |
110 | | - |
111 | | - |
112 | | -async def test_list_releases_with_mocked_catalog( |
113 | | - client: httpx.AsyncClient, |
114 | | - mocked_catalog_rpc_api: dict, |
115 | | - auth: httpx.BasicAuth, |
116 | | -): |
117 | | - response = await client.get(f"/{API_VTAG}/solvers/releases", auth=auth) |
118 | | - assert response.status_code == status.HTTP_200_OK |
119 | | - |
120 | | - |
121 | | -async def test_list_solver_page_with_mocked_catalog( |
122 | | - client: httpx.AsyncClient, |
123 | | - mocked_catalog_rpc_api: dict, |
124 | | - auth: httpx.BasicAuth, |
125 | | -): |
126 | | - response = await client.get(f"/{API_VTAG}/solvers/page", auth=auth) |
127 | | - assert response.status_code == status.HTTP_200_OK |
128 | | - assert len(response.json()["items"]) == response.json()["total"] |
129 | | - |
130 | | - |
131 | | -async def test_list_solver_releases_page_with_mocked_catalog( |
132 | | - client: httpx.AsyncClient, |
133 | | - mocked_catalog_rpc_api: dict, |
134 | | - auth: httpx.BasicAuth, |
135 | | -): |
136 | | - solver_key = "simcore/services/comp/itis/sleeper" |
137 | | - response = await client.get( |
138 | | - f"/{API_VTAG}/solvers/{solver_key}/releases/page", auth=auth |
139 | | - ) |
140 | | - assert response.status_code == status.HTTP_200_OK |
141 | | - assert len(response.json()["items"]) == response.json()["total"] |
142 | | - |
143 | | - |
144 | | -async def test_list_solver_releases_with_mocked_catalog( |
145 | | - client: httpx.AsyncClient, |
146 | | - mocked_catalog_rpc_api: dict, |
147 | | - auth: httpx.BasicAuth, |
148 | | -): |
149 | | - solver_key = "simcore/services/comp/itis/sleeper" |
150 | | - response = await client.get(f"/{API_VTAG}/solvers/{solver_key}/releases", auth=auth) |
151 | | - assert response.status_code == status.HTTP_200_OK |
152 | | - |
153 | | - |
154 | | -async def test_list_solver_ports_with_mocked_catalog( |
| 123 | +async def test_list_solver_ports_again( |
| 124 | + mocked_catalog_rpc_api: dict[str, MockType], |
155 | 125 | client: httpx.AsyncClient, |
156 | | - mocked_catalog_rpc_api: dict, |
157 | 126 | auth: httpx.BasicAuth, |
158 | 127 | ): |
159 | 128 | solver_key = "simcore/services/comp/itis/sleeper" |
|
0 commit comments