|
11 | 11 | from unittest import mock |
12 | 12 |
|
13 | 13 | import pytest |
14 | | -import simcore_service_webserver.studies_dispatcher |
15 | 14 | import sqlalchemy as sa |
16 | 15 | from aiohttp import ClientResponse, ClientSession |
17 | 16 | from aiohttp.test_utils import TestClient, TestServer |
|
20 | 19 | from common_library.serialization import model_dump_with_secrets |
21 | 20 | from common_library.users_enums import UserRole |
22 | 21 | from models_library.projects_state import ProjectShareState, ProjectStatus |
23 | | -from pydantic import BaseModel, ByteSize, TypeAdapter |
| 22 | +from pydantic import ByteSize, TypeAdapter |
24 | 23 | from pytest_mock import MockerFixture |
25 | 24 | from pytest_simcore.helpers.assert_checks import assert_status |
26 | 25 | from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict |
27 | 26 | from pytest_simcore.helpers.typing_env import EnvVarsDict |
28 | 27 | from pytest_simcore.helpers.webserver_users import UserInfoDict |
29 | | -from pytest_simcore.pydantic_models import ( |
30 | | - assert_validation_model, |
31 | | - walk_model_examples_in_package, |
32 | | -) |
33 | 28 | from servicelib.aiohttp import status |
34 | 29 | from settings_library.rabbit import RabbitSettings |
35 | 30 | from settings_library.redis import RedisSettings |
36 | 31 | from settings_library.utils_session import DEFAULT_SESSION_COOKIE_NAME |
37 | | -from simcore_service_webserver.studies_dispatcher._controller.rest.nih_schemas import ( |
38 | | - ServiceGet, |
39 | | -) |
40 | 32 | from simcore_service_webserver.studies_dispatcher._models import ViewerInfo |
41 | 33 | from sqlalchemy.sql import text |
42 | 34 | from yarl import URL |
@@ -183,123 +175,6 @@ async def director_v2_automock( |
183 | 175 | ] |
184 | 176 |
|
185 | 177 |
|
186 | | -# REST-API |
187 | | -# Samples taken from trials on http://127.0.0.1:9081/dev/doc#/viewer/get_viewer_for_file |
188 | | -# |
189 | | - |
190 | | - |
191 | | -def _get_base_url(client: TestClient) -> str: |
192 | | - s = client.server |
193 | | - assert isinstance(s.scheme, str) |
194 | | - url = URL.build(scheme=s.scheme, host=s.host, port=s.port) |
195 | | - return f"{url}" |
196 | | - |
197 | | - |
198 | | -async def test_api_get_viewer_for_file(client: TestClient): |
199 | | - resp = await client.get("/v0/viewers/default?file_type=JPEG") |
200 | | - data, _ = await assert_status(resp, status.HTTP_200_OK) |
201 | | - |
202 | | - base_url = _get_base_url(client) |
203 | | - assert data == [ |
204 | | - { |
205 | | - "file_type": "JPEG", |
206 | | - "title": "Bio-formats v1.0.1", |
207 | | - "view_url": f"{base_url}/view?file_type=JPEG&viewer_key=simcore/services/dynamic/bio-formats-web&viewer_version=1.0.1", |
208 | | - }, |
209 | | - ] |
210 | | - |
211 | | - |
212 | | -async def test_api_get_viewer_for_unsupported_type(client: TestClient): |
213 | | - resp = await client.get("/v0/viewers/default?file_type=UNSUPPORTED_TYPE") |
214 | | - data, error = await assert_status(resp, status.HTTP_200_OK) |
215 | | - assert data == [] |
216 | | - assert error is None |
217 | | - |
218 | | - |
219 | | -async def test_api_list_supported_filetypes(client: TestClient): |
220 | | - resp = await client.get("/v0/viewers/default") |
221 | | - data, _ = await assert_status(resp, status.HTTP_200_OK) |
222 | | - |
223 | | - base_url = _get_base_url(client) |
224 | | - assert data == [ |
225 | | - { |
226 | | - "title": "Rawgraphs v2.11.1", |
227 | | - "file_type": "CSV", |
228 | | - "view_url": f"{base_url}/view?file_type=CSV&viewer_key=simcore/services/dynamic/raw-graphs&viewer_version=2.11.1", |
229 | | - }, |
230 | | - { |
231 | | - "title": "Jupyterlab math v1.6.9", |
232 | | - "file_type": "IPYNB", |
233 | | - "view_url": f"{base_url}/view?file_type=IPYNB&viewer_key=simcore/services/dynamic/jupyter-octave-python-math&viewer_version=1.6.9", |
234 | | - }, |
235 | | - { |
236 | | - "title": "Bio-formats v1.0.1", |
237 | | - "file_type": "JPEG", |
238 | | - "view_url": f"{base_url}/view?file_type=JPEG&viewer_key=simcore/services/dynamic/bio-formats-web&viewer_version=1.0.1", |
239 | | - }, |
240 | | - { |
241 | | - "title": "Rawgraphs v2.11.1", |
242 | | - "file_type": "JSON", |
243 | | - "view_url": f"{base_url}/view?file_type=JSON&viewer_key=simcore/services/dynamic/raw-graphs&viewer_version=2.11.1", |
244 | | - }, |
245 | | - { |
246 | | - "title": "Bio-formats v1.0.1", |
247 | | - "file_type": "PNG", |
248 | | - "view_url": f"{base_url}/view?file_type=PNG&viewer_key=simcore/services/dynamic/bio-formats-web&viewer_version=1.0.1", |
249 | | - }, |
250 | | - { |
251 | | - "title": "Jupyterlab math v1.6.9", |
252 | | - "file_type": "PY", |
253 | | - "view_url": f"{base_url}/view?file_type=PY&viewer_key=simcore/services/dynamic/jupyter-octave-python-math&viewer_version=1.6.9", |
254 | | - }, |
255 | | - { |
256 | | - "title": "Rawgraphs v2.11.1", |
257 | | - "file_type": "TSV", |
258 | | - "view_url": f"{base_url}/view?file_type=TSV&viewer_key=simcore/services/dynamic/raw-graphs&viewer_version=2.11.1", |
259 | | - }, |
260 | | - { |
261 | | - "title": "Rawgraphs v2.11.1", |
262 | | - "file_type": "XLSX", |
263 | | - "view_url": f"{base_url}/view?file_type=XLSX&viewer_key=simcore/services/dynamic/raw-graphs&viewer_version=2.11.1", |
264 | | - }, |
265 | | - ] |
266 | | - |
267 | | - |
268 | | -@pytest.mark.parametrize( |
269 | | - "model_cls, example_name, example_data", |
270 | | - walk_model_examples_in_package(simcore_service_webserver.studies_dispatcher), |
271 | | -) |
272 | | -def test_model_examples( |
273 | | - model_cls: type[BaseModel], example_name: str, example_data: Any |
274 | | -): |
275 | | - assert_validation_model( |
276 | | - model_cls, example_name=example_name, example_data=example_data |
277 | | - ) |
278 | | - |
279 | | - |
280 | | -async def test_api_list_services(client: TestClient): |
281 | | - assert client.app |
282 | | - |
283 | | - url = client.app.router["list_latest_services"].url_for() |
284 | | - response = await client.get(f"{url}") |
285 | | - |
286 | | - data, error = await assert_status(response, status.HTTP_200_OK) |
287 | | - |
288 | | - services = TypeAdapter(list[ServiceGet]).validate_python(data) |
289 | | - assert services |
290 | | - |
291 | | - # latest versions of services with everyone + ospar-product (see stmt_create_services_access_rights) |
292 | | - assert services[0].key == "simcore/services/dynamic/raw-graphs" |
293 | | - assert services[0].file_extensions == ["CSV", "JSON", "TSV", "XLSX"] |
294 | | - assert "2.11.1" in services[0].view_url.query |
295 | | - |
296 | | - assert services[1].key == "simcore/services/dynamic/jupyter-octave-python-math" |
297 | | - assert services[1].file_extensions == ["IPYNB", "PY"] |
298 | | - assert "1.6.9" in services[1].view_url.query |
299 | | - |
300 | | - assert error is None |
301 | | - |
302 | | - |
303 | 178 | # REDIRECT ROUTES -------------------------------------------------------------------------------- |
304 | 179 |
|
305 | 180 |
|
|
0 commit comments