Skip to content

Commit 41ed118

Browse files
committed
fixed tests
1 parent b61359e commit 41ed118

File tree

7 files changed

+23
-2
lines changed

7 files changed

+23
-2
lines changed

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_route_computations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def minimal_configuration(
8888
faker: Faker,
8989
with_disabled_auto_scheduling: mock.Mock,
9090
with_disabled_scheduler_publisher: mock.Mock,
91+
product_db: dict[str, Any],
9192
):
9293
monkeypatch.setenv("DIRECTOR_V2_DYNAMIC_SIDECAR_ENABLED", "false")
9394
monkeypatch.setenv("COMPUTATIONAL_BACKEND_DASK_CLIENT_ENABLED", "1")
@@ -374,7 +375,7 @@ async def test_computation_create_validators(
374375
fake_workbench_without_outputs: dict[str, Any],
375376
product_name: str,
376377
product_api_base_url: AnyHttpUrl,
377-
faker: Faker,
378+
product_db: dict[str, Any],
378379
):
379380
user = create_registered_user()
380381
proj = await project(user, workbench=fake_workbench_without_outputs)

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_route_computations_tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ async def project_id(
120120
project: Callable[..., Awaitable[ProjectAtDB]],
121121
create_pipeline: Callable[..., Awaitable[CompPipelineAtDB]],
122122
create_tasks: Callable[..., Awaitable[list[CompTaskAtDB]]],
123+
product_db: dict[str, Any],
123124
) -> ProjectID:
124125
"""project uuid of a saved project (w/ tasks up-to-date)"""
125126

@@ -133,6 +134,7 @@ async def project_id(
133134
)
134135
# insert tasks -> comp_tasks
135136
comp_tasks = await create_tasks(user=user, project=proj)
137+
assert comp_tasks
136138

137139
return proj.uuid
138140

@@ -166,7 +168,7 @@ async def test_get_all_tasks_log_files(
166168
assert resp.status_code == status.HTTP_200_OK
167169
log_files = TypeAdapter(list[TaskLogFileGet]).validate_json(resp.text)
168170
assert log_files
169-
assert all(l.download_link for l in log_files)
171+
assert all(file.download_link for file in log_files)
170172

171173

172174
async def test_get_task_logs_file(

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_rpc_computations.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async def test_rpc_list_computation_runs_and_tasks(
4040
create_tasks: Callable[..., Awaitable[list[CompTaskAtDB]]],
4141
create_comp_run: Callable[..., Awaitable[CompRunsAtDB]],
4242
rpc_client: RabbitMQRPCClient,
43+
product_db: dict[str, Any],
4344
):
4445
user = create_registered_user()
4546
proj = await project(user, workbench=fake_workbench_without_outputs)
@@ -119,6 +120,7 @@ async def test_rpc_list_computation_runs_with_filtering(
119120
create_tasks: Callable[..., Awaitable[list[CompTaskAtDB]]],
120121
create_comp_run: Callable[..., Awaitable[CompRunsAtDB]],
121122
rpc_client: RabbitMQRPCClient,
123+
product_db: dict[str, Any],
122124
):
123125
user = create_registered_user()
124126

@@ -175,6 +177,7 @@ async def test_rpc_list_computation_runs_history(
175177
create_tasks: Callable[..., Awaitable[list[CompTaskAtDB]]],
176178
create_comp_run: Callable[..., Awaitable[CompRunsAtDB]],
177179
rpc_client: RabbitMQRPCClient,
180+
product_db: dict[str, Any],
178181
):
179182
user = create_registered_user()
180183

@@ -186,6 +189,7 @@ async def test_rpc_list_computation_runs_history(
186189
comp_tasks = await create_tasks(
187190
user=user, project=proj, state=StateType.PUBLISHED, progress=None
188191
)
192+
assert comp_tasks
189193
comp_runs_1 = await create_comp_run(
190194
user=user,
191195
project=proj,
@@ -195,6 +199,7 @@ async def test_rpc_list_computation_runs_history(
195199
iteration=1,
196200
dag_adjacency_list=fake_workbench_adjacency,
197201
)
202+
assert comp_runs_1
198203
comp_runs_2 = await create_comp_run(
199204
user=user,
200205
project=proj,
@@ -204,6 +209,7 @@ async def test_rpc_list_computation_runs_history(
204209
iteration=2,
205210
dag_adjacency_list=fake_workbench_adjacency,
206211
)
212+
assert comp_runs_2
207213
comp_runs_3 = await create_comp_run(
208214
user=user,
209215
project=proj,
@@ -213,6 +219,7 @@ async def test_rpc_list_computation_runs_history(
213219
iteration=3,
214220
dag_adjacency_list=fake_workbench_adjacency,
215221
)
222+
assert comp_runs_3
216223

217224
output = await rpc_computations.list_computations_iterations_page(
218225
rpc_client, product_name="osparc", user_id=user["id"], project_ids=[proj.uuid]

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ async def test_manager_starts_and_auto_schedules_pipelines(
8282
mocked_schedule_all_pipelines: mock.Mock,
8383
initialized_app: FastAPI,
8484
sqlalchemy_async_engine: AsyncEngine,
85+
product_db: dict[str, Any],
8586
):
8687
await assert_comp_runs_empty(sqlalchemy_async_engine)
8788
mocked_schedule_all_pipelines.assert_called()
@@ -93,6 +94,7 @@ async def test_schedule_all_pipelines_empty_db(
9394
initialized_app: FastAPI,
9495
scheduler_rabbit_client_parser: mock.AsyncMock,
9596
sqlalchemy_async_engine: AsyncEngine,
97+
product_db: dict[str, Any],
9698
):
9799
await assert_comp_runs_empty(sqlalchemy_async_engine)
98100

@@ -109,6 +111,7 @@ async def test_schedule_all_pipelines_concurently_runs_exclusively_and_raises(
109111
with_disabled_auto_scheduling: mock.Mock,
110112
initialized_app: FastAPI,
111113
mocker: MockerFixture,
114+
product_db: dict[str, Any],
112115
):
113116
CONCURRENCY = 5
114117
# NOTE: this ensure no flakyness as empty scheduling is very fast
@@ -320,6 +323,7 @@ async def test_empty_pipeline_is_not_scheduled(
320323
with_disabled_auto_scheduling: mock.Mock,
321324
with_disabled_scheduler_worker: mock.Mock,
322325
initialized_app: FastAPI,
326+
product_db: dict[str, Any],
323327
create_registered_user: Callable[..., dict[str, Any]],
324328
project: Callable[..., Awaitable[ProjectAtDB]],
325329
create_pipeline: Callable[..., Awaitable[CompPipelineAtDB]],

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_scheduler_dask.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ async def with_started_project(
965965
instrumentation_rabbit_client_parser: mock.AsyncMock,
966966
resource_tracking_rabbit_client_parser: mock.AsyncMock,
967967
computational_pipeline_rabbit_client_parser: mock.AsyncMock,
968+
product_db: dict[str, Any],
968969
) -> RunningProject:
969970
with_disabled_auto_scheduling.assert_called_once()
970971
published_project = await publish_project()
@@ -1210,6 +1211,7 @@ async def test_broken_pipeline_configuration_is_not_scheduled_and_aborted(
12101211
sqlalchemy_async_engine: AsyncEngine,
12111212
run_metadata: RunMetadataDict,
12121213
computational_pipeline_rabbit_client_parser: mock.AsyncMock,
1214+
product_db: dict[str, Any],
12131215
):
12141216
"""A pipeline which comp_tasks are missing should not be scheduled.
12151217
It shall be aborted and shown as such in the comp_runs db"""

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_worker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import asyncio
1111
from collections.abc import Awaitable, Callable
12+
from typing import Any
1213
from unittest import mock
1314

1415
import pytest
@@ -109,6 +110,7 @@ async def test_worker_scheduling_parallelism(
109110
initialized_app: FastAPI,
110111
publish_project: Callable[[], Awaitable[PublishedProject]],
111112
run_metadata: RunMetadataDict,
113+
product_db: dict[str, Any],
112114
):
113115
with_disabled_auto_scheduling.assert_called_once()
114116

services/director-v2/tests/unit/with_dbs/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,15 @@ async def _() -> PublishedProject:
342342

343343
@pytest.fixture
344344
async def published_project(
345+
product_db: dict[str, Any],
345346
publish_project: Callable[[], Awaitable[PublishedProject]],
346347
) -> PublishedProject:
347348
return await publish_project()
348349

349350

350351
@pytest.fixture
351352
async def running_project(
353+
product_db: dict[str, Any],
352354
create_registered_user: Callable[..., dict[str, Any]],
353355
project: Callable[..., Awaitable[ProjectAtDB]],
354356
create_pipeline: Callable[..., Awaitable[CompPipelineAtDB]],
@@ -409,6 +411,7 @@ async def running_project_mark_for_cancellation(
409411
],
410412
fake_workbench_without_outputs: dict[str, Any],
411413
fake_workbench_adjacency: dict[str, Any],
414+
product_db: dict[str, Any],
412415
) -> RunningProject:
413416
user = create_registered_user()
414417
created_project = await project(user, workbench=fake_workbench_without_outputs)

0 commit comments

Comments
 (0)