Skip to content

Commit

Permalink
unblocking hanging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Neagu committed Dec 18, 2024
1 parent 7281f23 commit 5c36635
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 15 additions & 2 deletions services/web/server/tests/unit/with_dbs/02/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -658,30 +654,19 @@ 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",
[
(UserRole.ANONYMOUS, status.HTTP_401_UNAUTHORIZED),
*((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()

Expand All @@ -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

0 comments on commit 5c36635

Please sign in to comment.