From 5c36635641097f36660cb2f1a736a4816ab3eca0 Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 18 Dec 2024 12:15:26 +0100 Subject: [PATCH] unblocking hanging tests --- .../server/tests/unit/with_dbs/02/conftest.py | 17 +++++++++++++++-- .../with_dbs/02/test_projects_crud_handlers.py | 17 +---------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/services/web/server/tests/unit/with_dbs/02/conftest.py b/services/web/server/tests/unit/with_dbs/02/conftest.py index 148d6315d8d..ba6ffa2e327 100644 --- a/services/web/server/tests/unit/with_dbs/02/conftest.py +++ b/services/web/server/tests/unit/with_dbs/02/conftest.py @@ -17,7 +17,10 @@ from aiohttp.test_utils import TestClient from aioresponses import aioresponses from faker import Faker -from models_library.api_schemas_directorv2.dynamic_services import DynamicServiceGet +from models_library.api_schemas_directorv2.dynamic_services import ( + DynamicServiceGet, + GetProjectInactivityResponse, +) from models_library.projects_nodes import Node, NodeID from models_library.projects_state import ProjectState from models_library.services_resources import ( @@ -264,9 +267,19 @@ async def _assert_it( return _assert_it +@pytest.fixture +def disable_dynamic_scheduler_inactivity(mocker: MockerFixture) -> None: + mocker.patch( + "simcore_service_webserver.projects.projects_api.dynamic_scheduler_api.get_project_inactivity", + return_value=GetProjectInactivityResponse(is_inactive=True), + ) + + @pytest.fixture def app_environment( - app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch + app_environment: EnvVarsDict, + monkeypatch: pytest.MonkeyPatch, + disable_dynamic_scheduler_inactivity: None, ) -> EnvVarsDict: envs_plugins = setenvs_from_dict( monkeypatch, diff --git a/services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers.py b/services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers.py index d494d98f446..3747723ecb6 100644 --- a/services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers.py +++ b/services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers.py @@ -15,13 +15,9 @@ from aiohttp.test_utils import TestClient from aioresponses import aioresponses from faker import Faker -from models_library.api_schemas_directorv2.dynamic_services import ( - GetProjectInactivityResponse, -) from models_library.products import ProductName from models_library.projects_state import ProjectState from pydantic import TypeAdapter -from pytest_mock import MockerFixture from pytest_simcore.helpers.assert_checks import assert_status from pytest_simcore.helpers.webserver_login import UserInfoDict from pytest_simcore.helpers.webserver_parametrizations import ( @@ -658,14 +654,6 @@ async def test_new_template_from_project( TypeAdapter(uuidlib.UUID).validate_python(node_name) -@pytest.fixture -def mock_dynamic_scheduler_inactivity(mocker: MockerFixture, is_inactive: bool) -> None: - mocker.patch( - "simcore_service_webserver.projects.projects_api.dynamic_scheduler_api.get_project_inactivity", - return_value=GetProjectInactivityResponse(is_inactive=is_inactive), - ) - - @pytest.mark.parametrize( "user_role,expected", [ @@ -673,15 +661,12 @@ def mock_dynamic_scheduler_inactivity(mocker: MockerFixture, is_inactive: bool) *((role, status.HTTP_200_OK) for role in UserRole if role > UserRole.ANONYMOUS), ], ) -@pytest.mark.parametrize("is_inactive", [True, False]) async def test_get_project_inactivity( - mock_dynamic_scheduler_inactivity: None, logged_user: UserInfoDict, client: TestClient, faker: Faker, user_role: UserRole, expected: HTTPStatus, - is_inactive: bool, ): mock_project_id = faker.uuid4() @@ -697,4 +682,4 @@ async def test_get_project_inactivity( assert data assert error is None - assert data["is_inactive"] is is_inactive + assert data["is_inactive"] is True