Skip to content

Commit a5b1ecc

Browse files
fixes
1 parent c0b1e1b commit a5b1ecc

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async def test_list(
117117
metadata=run_metadata,
118118
use_on_demand_clusters=faker.pybool(),
119119
dag_adjacency_list=published_project.pipeline.dag_adjacency_list,
120-
collection_run_id=fake_collection_run_id,
120+
collection_run_id=faker.uuid4(),
121121
)
122122
for n in range(50)
123123
)
@@ -274,7 +274,6 @@ async def test_create(
274274
run_metadata: RunMetadataDict,
275275
faker: Faker,
276276
publish_project: Callable[[], Awaitable[PublishedProject]],
277-
fake_collection_run_id: CollectionRunID,
278277
):
279278
with pytest.raises(ProjectNotFoundError):
280279
await CompRunsRepository(sqlalchemy_async_engine).create(
@@ -284,7 +283,7 @@ async def test_create(
284283
metadata=run_metadata,
285284
use_on_demand_clusters=faker.pybool(),
286285
dag_adjacency_list={},
287-
collection_run_id=fake_collection_run_id,
286+
collection_run_id=faker.uuid4(),
288287
)
289288
published_project = await publish_project()
290289
with pytest.raises(UserNotFoundError):
@@ -295,7 +294,7 @@ async def test_create(
295294
metadata=run_metadata,
296295
use_on_demand_clusters=faker.pybool(),
297296
dag_adjacency_list=published_project.pipeline.dag_adjacency_list,
298-
collection_run_id=fake_collection_run_id,
297+
collection_run_id=faker.uuid4(),
299298
)
300299

301300
created = await CompRunsRepository(sqlalchemy_async_engine).create(
@@ -305,7 +304,7 @@ async def test_create(
305304
metadata=run_metadata,
306305
use_on_demand_clusters=faker.pybool(),
307306
dag_adjacency_list=published_project.pipeline.dag_adjacency_list,
308-
collection_run_id=fake_collection_run_id,
307+
collection_run_id=faker.uuid4(),
309308
)
310309
got = await CompRunsRepository(sqlalchemy_async_engine).get(
311310
user_id=published_project.user["id"],
@@ -321,7 +320,7 @@ async def test_create(
321320
metadata=run_metadata,
322321
use_on_demand_clusters=faker.pybool(),
323322
dag_adjacency_list=published_project.pipeline.dag_adjacency_list,
324-
collection_run_id=fake_collection_run_id,
323+
collection_run_id=faker.uuid4(),
325324
)
326325
assert created != got
327326
assert created.iteration == got.iteration + 1

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async def _assert_start_pipeline(
166166
published_project: PublishedProject,
167167
run_metadata: RunMetadataDict,
168168
computational_pipeline_rabbit_client_parser: mock.AsyncMock,
169-
fake_collection_run_id: CollectionRunID,
169+
collection_run_id: CollectionRunID,
170170
) -> tuple[CompRunsAtDB, list[CompTaskAtDB]]:
171171
exp_published_tasks = deepcopy(published_project.tasks)
172172
assert published_project.project.prj_owner
@@ -176,7 +176,7 @@ async def _assert_start_pipeline(
176176
project_id=published_project.project.uuid,
177177
run_metadata=run_metadata,
178178
use_on_demand_clusters=False,
179-
collection_run_id=fake_collection_run_id,
179+
collection_run_id=collection_run_id,
180180
)
181181

182182
# check the database is correctly updated, the run is published

services/web/server/tests/unit/with_dbs/01/test_director_v2_handlers.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,49 @@ async def test_list_computations_latest_iteration(
241241
)
242242
if user_role != UserRole.ANONYMOUS:
243243
assert ComputationTaskRestGet.model_validate(data[0])
244+
245+
246+
@pytest.mark.parametrize(*standard_role_response(), ids=str)
247+
async def test_list_computations_latest_iteration(
248+
director_v2_service_mock: AioResponsesMock,
249+
user_project: ProjectDict,
250+
client: TestClient,
251+
logged_user: LoggedUser,
252+
user_role: UserRole,
253+
expected: ExpectedResponse,
254+
mock_rpc_list_computations_latest_iteration_tasks: None,
255+
mock_rpc_list_computations_latest_iteration_tasks_page: None,
256+
mock_rpc_list_computation_iterations: None,
257+
):
258+
assert client.app
259+
url = client.app.router["list_computations_latest_iteration"].url_for()
260+
resp = await client.get(f"{url}")
261+
data, _ = await assert_status(
262+
resp, status.HTTP_200_OK if user_role == UserRole.GUEST else expected.ok
263+
)
264+
if user_role != UserRole.ANONYMOUS:
265+
assert ComputationRunRestGet.model_validate(data[0])
266+
assert data[0]["rootProjectName"] == user_project["name"]
267+
268+
url = client.app.router["list_computation_iterations"].url_for(
269+
project_id=f"{user_project['uuid']}"
270+
)
271+
resp = await client.get(f"{url}")
272+
data, _ = await assert_status(
273+
resp, status.HTTP_200_OK if user_role == UserRole.GUEST else expected.ok
274+
)
275+
if user_role != UserRole.ANONYMOUS:
276+
assert ComputationRunRestGet.model_validate(data[0])
277+
assert len(data) == 2
278+
assert data[0]["rootProjectName"] == user_project["name"]
279+
assert data[1]["rootProjectName"] == user_project["name"]
280+
281+
url = client.app.router["list_computations_latest_iteration_tasks"].url_for(
282+
project_id=f"{user_project['uuid']}"
283+
)
284+
resp = await client.get(f"{url}")
285+
data, _ = await assert_status(
286+
resp, status.HTTP_200_OK if user_role == UserRole.GUEST else expected.ok
287+
)
288+
if user_role != UserRole.ANONYMOUS:
289+
assert ComputationTaskRestGet.model_validate(data[0])

0 commit comments

Comments
 (0)