Skip to content

Commit 0452113

Browse files
author
Andrei Neagu
committed
fixed tests which required redis
1 parent e526df5 commit 0452113

File tree

8 files changed

+20
-2
lines changed

8 files changed

+20
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pytest
2+
from servicelib.long_running_tasks import task
3+
from servicelib.long_running_tasks._store.in_memory import InMemoryStore
4+
5+
6+
@pytest.fixture
7+
def uese_in_memory_lonng_running_tasks_storage() -> None:
8+
task._StorageClass = InMemoryStore # pylint:disable=protected-access

packages/service-library/src/servicelib/long_running_tasks/_store/in_memory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44

55
class InMemoryStore(BaseStore):
6-
def __init__(self):
6+
def __init__(self, *args, **kwargs):
7+
_ = args
8+
_ = kwargs
79
self._tasks_data: dict[TaskId, TaskData] = {}
810
self._cancelled_tasks: dict[TaskId, TaskContext | None] = {}
911

packages/service-library/src/servicelib/long_running_tasks/task.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
_CANCEL_TASKS_CHECK_INTERVAL: Final[datetime.timedelta] = datetime.timedelta(seconds=5)
3939

40+
_StorageClass: Final[type[BaseStore]] = RedisStore
41+
4042
RegisteredTaskName: TypeAlias = str
4143
Namespace: TypeAlias = str
4244

@@ -109,7 +111,7 @@ def __init__(
109111
namespace: Namespace,
110112
):
111113
# Task groups: Every taskname maps to multiple asyncio.Task within TrackedTask model
112-
self._tasks_data: BaseStore = RedisStore(redis_settings, namespace)
114+
self._tasks_data: BaseStore = _StorageClass(redis_settings, namespace)
113115
self._created_tasks: dict[TaskId, asyncio.Task] = {}
114116

115117
self.stale_task_check_interval = stale_task_check_interval

services/director-v2/tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"pytest_simcore.faker_projects_data",
4949
"pytest_simcore.faker_users_data",
5050
"pytest_simcore.logging",
51+
"pytest_simcore.long_running_tasks",
5152
"pytest_simcore.minio_service",
5253
"pytest_simcore.postgres_service",
5354
"pytest_simcore.pydantic_models",

services/director-v2/tests/unit/test_api_route_dynamic_scheduler.py

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

2828
@pytest.fixture
2929
def mock_env(
30+
uese_in_memory_lonng_running_tasks_storage: None,
3031
mock_exclusive: None,
3132
disable_rabbitmq: None,
3233
disable_postgres: None,

services/director-v2/tests/unit/test_modules_dynamic_sidecar_scheduler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ async def _assert_get_dynamic_services_mocked(
124124

125125
@pytest.fixture
126126
def mock_env(
127+
uese_in_memory_lonng_running_tasks_storage: None,
127128
mock_exclusive: None,
128129
disable_postgres: None,
129130
disable_rabbitmq: None,

services/director-v2/tests/unit/test_modules_dynamic_sidecar_scheduler_task.py

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

4444
@pytest.fixture
4545
def mock_env(
46+
uese_in_memory_lonng_running_tasks_storage: None,
4647
disable_postgres: None,
4748
disable_rabbitmq: None,
4849
mock_env: EnvVarsDict,

services/dynamic-sidecar/tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"pytest_simcore.docker_swarm",
4242
"pytest_simcore.faker_users_data",
4343
"pytest_simcore.logging",
44+
"pytest_simcore.long_running_tasks",
4445
"pytest_simcore.minio_service",
4546
"pytest_simcore.postgres_service",
4647
"pytest_simcore.pytest_global_environs",
@@ -209,6 +210,7 @@ def base_mock_envs(
209210

210211
@pytest.fixture
211212
def mock_environment(
213+
uese_in_memory_lonng_running_tasks_storage: None,
212214
mock_storage_check: None,
213215
mock_postgres_check: None,
214216
mock_rabbit_check: None,

0 commit comments

Comments
 (0)