55import subprocess
66from collections .abc import AsyncIterable
77from contextlib import suppress
8+ from typing import Final
9+ from unittest .mock import AsyncMock
810
911import pytest
1012from fastapi import FastAPI , status
1618from pytest_simcore .helpers .typing_env import EnvVarsDict
1719from settings_library .rabbit import RabbitSettings
1820from settings_library .redis import RedisSettings
21+ from settings_library .utils_service import DEFAULT_FASTAPI_PORT
1922from simcore_service_dynamic_scheduler .core .application import create_app
2023from tenacity import AsyncRetrying , stop_after_delay , wait_fixed
2124
25+ _MODULE : Final ["str" ] = "simcore_service_dynamic_scheduler"
26+
2227
2328@pytest .fixture
2429def disable_status_monitor_background_task (mocker : MockerFixture ) -> None :
2530 mocker .patch (
26- "simcore_service_dynamic_scheduler.services.status_monitor._monitor.Monitor._worker_check_services_require_status_update"
31+ f"{ _MODULE } .services.status_monitor._monitor.Monitor._worker_check_services_require_status_update"
32+ )
33+
34+
35+ @pytest .fixture
36+ def mock_stop_dynamic_service (mocker : MockerFixture ) -> AsyncMock :
37+ async_mock = AsyncMock ()
38+ mocker .patch (
39+ f"{ _MODULE } .api.frontend.routes._service.stop_dynamic_service" , async_mock
40+ )
41+ return async_mock
42+
43+
44+ @pytest .fixture
45+ def mock_remove_tracked_service (mocker : MockerFixture ) -> AsyncMock :
46+ async_mock = AsyncMock ()
47+ mocker .patch (
48+ f"{ _MODULE } .api.frontend.routes._service.remove_tracked_service" , async_mock
2749 )
50+ return async_mock
2851
2952
3053@pytest .fixture
@@ -40,7 +63,7 @@ def app_environment(
4063
4164@pytest .fixture
4265def server_host_port () -> str :
43- return "127.0.0.1:7456 "
66+ return f "127.0.0.1:{ DEFAULT_FASTAPI_PORT } "
4467
4568
4669@pytest .fixture
0 commit comments