|
3 | 3 | # pylint: disable=unused-variable |
4 | 4 | # pylint: disable=too-many-arguments |
5 | 5 |
|
| 6 | +from datetime import datetime |
6 | 7 | from decimal import Decimal |
7 | 8 | from pathlib import Path |
8 | 9 | from typing import Any, Final |
|
15 | 16 | from fastapi.encoders import jsonable_encoder |
16 | 17 | from httpx import AsyncClient |
17 | 18 | from models_library.generics import Envelope |
18 | | -from models_library.products import ProductName |
19 | | -from models_library.projects import ProjectID |
20 | 19 | from models_library.rpc.webserver.projects import ProjectJobRpcGet |
21 | | -from models_library.users import UserID |
22 | | -from pydantic import TypeAdapter, validate_call |
23 | | -from pytest_mock import MockerFixture, MockType |
| 20 | +from pydantic import TypeAdapter |
| 21 | +from pytest_mock import MockType |
24 | 22 | from pytest_simcore.helpers.httpx_calls_capture_models import ( |
25 | 23 | CreateRespxMockCallback, |
26 | 24 | HttpApiCallCaptureModel, |
27 | 25 | SideEffectCallback, |
28 | 26 | ) |
29 | 27 | from respx import MockRouter |
30 | | -from servicelib.rabbitmq import RabbitMQRPCClient |
31 | 28 | from simcore_service_api_server._meta import API_VTAG |
32 | 29 | from simcore_service_api_server.models.schemas.jobs import Job, JobStatus |
33 | 30 | from simcore_service_api_server.models.schemas.model_adapter import ( |
@@ -352,56 +349,29 @@ async def test_start_solver_job_conflict( |
352 | 349 | assert f"{job_status.job_id}" == _job_id |
353 | 350 |
|
354 | 351 |
|
355 | | -@pytest.fixture |
356 | | -def mocked_get_project_marked_as_job_storage_data_missing( |
357 | | - mocked_app_dependencies: None, mocker: MockerFixture |
358 | | -) -> dict[str, MockType]: |
359 | | - """ |
360 | | - Mocks the webserver's simcore service RPC API for testing purposes. |
361 | | - """ |
362 | | - from servicelib.rabbitmq.rpc_interfaces.webserver import ( |
363 | | - projects as projects_rpc, # keep import here |
364 | | - ) |
365 | | - |
366 | | - @validate_call(config={"arbitrary_types_allowed": True}) |
367 | | - async def _get_project_marked_as_job( |
368 | | - rpc_client: RabbitMQRPCClient | MockType, |
369 | | - *, |
370 | | - product_name: ProductName, |
371 | | - user_id: UserID, |
372 | | - project_uuid: ProjectID, |
373 | | - job_parent_resource_name: str, |
374 | | - ) -> ProjectJobRpcGet: |
375 | | - assert rpc_client |
376 | | - assert product_name |
377 | | - assert user_id |
378 | | - assert project_uuid |
379 | | - assert job_parent_resource_name |
380 | | - |
381 | | - # Return a valid example from the schema |
382 | | - example = ProjectJobRpcGet.model_json_schema()["examples"][0] |
383 | | - example["uuid"] = str(project_uuid) |
384 | | - example["job_parent_resource_name"] = job_parent_resource_name |
385 | | - example["storage_data_deleted"] = "true" |
386 | | - project_job_rpc_get = ProjectJobRpcGet.model_validate(example) |
387 | | - assert project_job_rpc_get.storage_data_deleted is True |
388 | | - return project_job_rpc_get |
389 | | - |
390 | | - return { |
391 | | - "get_project_marked_as_job": mocker.patch.object( |
392 | | - projects_rpc, |
393 | | - "get_project_marked_as_job", |
394 | | - autospec=True, |
395 | | - side_effect=_get_project_marked_as_job, |
396 | | - ), |
397 | | - } |
398 | | - |
399 | | - |
| 352 | +@pytest.mark.parametrize( |
| 353 | + "project_job_rpc_get", |
| 354 | + [ |
| 355 | + pytest.param( |
| 356 | + ProjectJobRpcGet( |
| 357 | + uuid=UUID("00000000-1234-5678-1234-123456789012"), |
| 358 | + name="A study job", |
| 359 | + description="A description of a study job with many node", |
| 360 | + workbench={}, |
| 361 | + created_at=datetime.fromisoformat("2023-02-01T00:00:00Z"), |
| 362 | + modified_at=datetime.fromisoformat("2023-02-01T00:00:00Z"), |
| 363 | + job_parent_resource_name="studies/96642f2a-a72c-11ef-8776-02420a00087d", |
| 364 | + storage_data_deleted=True, |
| 365 | + ), |
| 366 | + id="storage_data_deleted", |
| 367 | + ) |
| 368 | + ], |
| 369 | +) |
400 | 370 | async def test_start_solver_job_storage_data_missing( |
401 | 371 | client: AsyncClient, |
402 | 372 | mocked_webserver_rest_api_base: MockRouter, |
403 | 373 | mocked_directorv2_rest_api_base: MockRouter, |
404 | | - mocked_get_project_marked_as_job_storage_data_missing: dict[str, MockType], |
| 374 | + mocked_webserver_rpc_api: dict[str, MockType], |
405 | 375 | create_respx_mock_from_capture: CreateRespxMockCallback, |
406 | 376 | auth: httpx.BasicAuth, |
407 | 377 | project_tests_dir: Path, |
|
0 commit comments