Skip to content

Commit f7b4c2a

Browse files
author
Andrei Neagu
committed
fixed all tests
1 parent b16c6b7 commit f7b4c2a

14 files changed

+42
-9
lines changed

services/dynamic-scheduler/tests/conftest.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"pytest_simcore.environment_configs",
2828
"pytest_simcore.faker_projects_data",
2929
"pytest_simcore.faker_users_data",
30+
"pytest_simcore.faker_users_data",
3031
"pytest_simcore.postgres_service",
3132
"pytest_simcore.rabbit_service",
3233
"pytest_simcore.redis_service",
@@ -84,38 +85,55 @@ def app_environment(
8485
)
8586

8687

87-
_PATH_APPLICATION: Final[str] = "simcore_service_dynamic_scheduler.core.events"
88+
_EVENTS_MODULE: Final[str] = "simcore_service_dynamic_scheduler.core.events"
8889

8990

9091
@pytest.fixture
9192
def disable_rabbitmq_lifespan(mocker: MockerFixture) -> None:
92-
mocker.patch(f"{_PATH_APPLICATION}.rabbitmq_lifespan")
93-
mocker.patch(f"{_PATH_APPLICATION}.rpc_api_routes_lifespan")
93+
mocker.patch(f"{_EVENTS_MODULE}.rabbitmq_lifespan")
94+
mocker.patch(f"{_EVENTS_MODULE}.rpc_api_routes_lifespan")
9495

9596

9697
@pytest.fixture
9798
def disable_redis_lifespan(mocker: MockerFixture) -> None:
98-
mocker.patch(f"{_PATH_APPLICATION}.redis_lifespan")
99+
mocker.patch(f"{_EVENTS_MODULE}.redis_lifespan")
99100

100101

101102
@pytest.fixture
102103
def disable_service_tracker_lifespan(mocker: MockerFixture) -> None:
103-
mocker.patch(f"{_PATH_APPLICATION}.service_tracker_lifespan")
104+
mocker.patch(f"{_EVENTS_MODULE}.service_tracker_lifespan")
104105

105106

106107
@pytest.fixture
107108
def disable_deferred_manager_lifespan(mocker: MockerFixture) -> None:
108-
mocker.patch(f"{_PATH_APPLICATION}.deferred_manager_lifespan")
109+
mocker.patch(f"{_EVENTS_MODULE}.deferred_manager_lifespan")
109110

110111

111112
@pytest.fixture
112113
def disable_notifier_lifespan(mocker: MockerFixture) -> None:
113-
mocker.patch(f"{_PATH_APPLICATION}.get_notifier_lifespans")
114+
mocker.patch(f"{_EVENTS_MODULE}.get_notifier_lifespans")
114115

115116

116117
@pytest.fixture
117118
def disable_status_monitor_lifespan(mocker: MockerFixture) -> None:
118-
mocker.patch(f"{_PATH_APPLICATION}.status_monitor_lifespan")
119+
mocker.patch(f"{_EVENTS_MODULE}.status_monitor_lifespan")
120+
121+
122+
@pytest.fixture
123+
def disable_postgres_lifespan(
124+
mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch
125+
) -> None:
126+
setenvs_from_dict(
127+
monkeypatch,
128+
{
129+
"POSTGRES_USER": "test_user",
130+
"POSTGRES_PASSWORD": "test_password",
131+
"POSTGRES_DB": "test_db",
132+
"POSTGRES_HOST": "test_host",
133+
},
134+
)
135+
136+
mocker.patch(f"{_EVENTS_MODULE}.repository_lifespan_manager")
119137

120138

121139
MAX_TIME_FOR_APP_TO_STARTUP: Final[float] = 10

services/dynamic-scheduler/tests/unit/api_frontend/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
import nicegui
1212
import pytest
13+
import sqlalchemy as sa
1314
from fastapi import FastAPI, status
1415
from httpx import AsyncClient
1516
from hypercorn.asyncio import serve
1617
from hypercorn.config import Config
1718
from playwright.async_api import Page, async_playwright
1819
from pytest_mock import MockerFixture
20+
from pytest_simcore.helpers.postgres_tools import PostgresTestConfig
1921
from pytest_simcore.helpers.typing_env import EnvVarsDict
2022
from settings_library.rabbit import RabbitSettings
2123
from settings_library.redis import RedisSettings
@@ -55,6 +57,8 @@ def mock_remove_tracked_service(mocker: MockerFixture) -> AsyncMock:
5557
@pytest.fixture
5658
def app_environment(
5759
app_environment: EnvVarsDict,
60+
postgres_db: sa.engine.Engine,
61+
postgres_host_config: PostgresTestConfig,
5862
disable_status_monitor_background_task: None,
5963
rabbit_service: RabbitSettings,
6064
redis_service: RedisSettings,

services/dynamic-scheduler/tests/unit/api_frontend/test_api_frontend_routes_index.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from tenacity import AsyncRetrying, stop_after_delay, wait_fixed
3333

3434
pytest_simcore_core_services_selection = [
35+
"postgres",
3536
"rabbit",
3637
"redis",
3738
]

services/dynamic-scheduler/tests/unit/api_frontend/test_api_frontend_routes_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from tenacity import AsyncRetrying, stop_after_delay, wait_fixed
2929

3030
pytest_simcore_core_services_selection = [
31+
"postgres",
3132
"rabbit",
3233
"redis",
3334
]

services/dynamic-scheduler/tests/unit/api_rest/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@pytest.fixture
1313
def app_environment(
14+
disable_postgres_lifespan: None,
1415
disable_rabbitmq_lifespan: None,
1516
disable_redis_lifespan: None,
1617
disable_service_tracker_lifespan: None,

services/dynamic-scheduler/tests/unit/api_rest/test_api_rest__meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from simcore_service_dynamic_scheduler.models.schemas.meta import Meta
77

88

9-
async def test_health(client: AsyncClient):
9+
async def test_meta(client: AsyncClient):
1010
response = await client.get(f"/{API_VTAG}/meta")
1111
assert response.status_code == status.HTTP_200_OK
1212
assert Meta.model_validate_json(response.text)

services/dynamic-scheduler/tests/unit/api_rpc/test_api_rpc__services.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def app_environment(
179179

180180
@pytest.fixture
181181
async def rpc_client(
182+
disable_postgres_lifespan: None,
182183
app_environment: EnvVarsDict,
183184
mock_director_v2_service_state: None,
184185
mock_director_v0_service_state: None,

services/dynamic-scheduler/tests/unit/service_tracker/test__api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
@pytest.fixture
5454
def app_environment(
55+
disable_postgres_lifespan: None,
5556
disable_rabbitmq_lifespan: None,
5657
disable_deferred_manager_lifespan: None,
5758
disable_notifier_lifespan: None,

services/dynamic-scheduler/tests/unit/service_tracker/test__tracker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def disable_monitor_task(mocker: MockerFixture) -> None:
3535

3636
@pytest.fixture
3737
def app_environment(
38+
disable_postgres_lifespan: None,
3839
disable_monitor_task: None,
3940
disable_rabbitmq_lifespan: None,
4041
disable_deferred_manager_lifespan: None,

services/dynamic-scheduler/tests/unit/status_monitor/test_services_status_monitor__monitor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
@pytest.fixture
6363
def app_environment(
64+
disable_postgres_lifespan: None,
6465
app_environment: EnvVarsDict,
6566
rabbit_service: RabbitSettings,
6667
redis_service: RedisSettings,

0 commit comments

Comments
 (0)