Skip to content

Commit a73f920

Browse files
author
Andrei Neagu
committed
fixed tests
1 parent afb6eac commit a73f920

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

packages/service-library/tests/fastapi/long_running_tasks/conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
from fastapi import FastAPI
1010
from httpx import ASGITransport, AsyncClient
1111
from servicelib.fastapi import long_running_tasks
12+
from settings_library.redis import RedisSettings
1213

1314

1415
@pytest.fixture
15-
async def bg_task_app(router_prefix: str) -> FastAPI:
16+
async def bg_task_app(router_prefix: str, redis_service: RedisSettings) -> FastAPI:
1617
app = FastAPI()
1718

18-
long_running_tasks.server.setup(app, router_prefix=router_prefix)
19+
long_running_tasks.server.setup(
20+
app, redis_settings=redis_service, namespace="test", router_prefix=router_prefix
21+
)
1922
return app
2023

2124

packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@
3333
TaskStatus,
3434
)
3535
from servicelib.long_running_tasks.task import TaskContext, TaskRegistry
36+
from settings_library.redis import RedisSettings
3637
from tenacity.asyncio import AsyncRetrying
3738
from tenacity.retry import retry_if_exception_type
3839
from tenacity.stop import stop_after_delay
3940
from tenacity.wait import wait_fixed
4041
from yarl import URL
4142

43+
pytest_simcore_core_services_selection = [
44+
"redis",
45+
]
46+
4247
ITEM_PUBLISH_SLEEP: Final[float] = 0.1
4348

4449

@@ -91,11 +96,13 @@ async def create_string_list_task(
9196

9297

9398
@pytest.fixture
94-
async def app(server_routes: APIRouter) -> AsyncIterator[FastAPI]:
99+
async def app(
100+
server_routes: APIRouter, redis_service: RedisSettings
101+
) -> AsyncIterator[FastAPI]:
95102
# overrides fastapi/conftest.py:app
96103
app = FastAPI(title="test app")
97104
app.include_router(server_routes)
98-
setup_server(app)
105+
setup_server(app, redis_settings=redis_service, namespace="test")
99106
setup_client(app)
100107
async with LifespanManager(app):
101108
yield app

packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks_context_manager.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
TaskProgress,
2929
)
3030
from servicelib.long_running_tasks.task import TaskRegistry
31+
from settings_library.redis import RedisSettings
32+
33+
pytest_simcore_core_services_selection = [
34+
"redis",
35+
]
3136

3237
TASK_SLEEP_INTERVAL: Final[PositiveFloat] = 0.1
3338

@@ -89,13 +94,15 @@ async def create_task_which_fails(
8994

9095
@pytest.fixture
9196
async def bg_task_app(
92-
user_routes: APIRouter, router_prefix: str
97+
user_routes: APIRouter, router_prefix: str, redis_service: RedisSettings
9398
) -> AsyncIterable[FastAPI]:
9499
app = FastAPI()
95100

96101
app.include_router(user_routes)
97102

98-
setup_server(app, router_prefix=router_prefix)
103+
setup_server(
104+
app, router_prefix=router_prefix, redis_settings=redis_service, namespace="test"
105+
)
99106
setup_client(app, router_prefix=router_prefix)
100107

101108
async with LifespanManager(app):

0 commit comments

Comments
 (0)