Skip to content

Commit abce4e6

Browse files
author
Andrei Neagu
committed
fixed tests
1 parent 3b2b9ea commit abce4e6

12 files changed

+39
-14
lines changed

services/web/server/tests/unit/with_dbs/02/conftest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ async def project_db_cleaner(client: TestClient):
239239

240240

241241
@pytest.fixture(autouse=True)
242-
async def mocked_director_v2_and_dynamic_scheduler_interfaces(
243-
mock_dynamic_scheduler: None, director_v2_service_mock: aioresponses
244-
) -> None:
242+
async def mocked_director_v2(director_v2_service_mock: aioresponses) -> None:
245243
pass
246244

247245

services/web/server/tests/unit/with_dbs/02/test_projects_cancellations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ async def test_copying_large_project_and_retrieving_copy_task(
180180

181181
@pytest.mark.parametrize(*_standard_user_role_response())
182182
async def test_creating_new_project_from_template_without_copying_data_creates_skeleton(
183+
mock_dynamic_scheduler: None,
183184
client: TestClient,
184185
logged_user: dict[str, Any],
185186
primary_group: dict[str, str],
@@ -230,6 +231,7 @@ async def test_creating_new_project_from_template_without_copying_data_creates_s
230231

231232
@pytest.mark.parametrize(*_standard_user_role_response())
232233
async def test_creating_new_project_as_template_without_copying_data_creates_skeleton(
234+
mock_dynamic_scheduler: None,
233235
client: TestClient,
234236
logged_user: dict[str, Any],
235237
primary_group: dict[str, str],

services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ async def test_get_project(
412412

413413
@pytest.mark.parametrize(*standard_role_response())
414414
async def test_new_project(
415+
mock_dynamic_scheduler: None,
415416
client: TestClient,
416417
logged_user: UserInfoDict,
417418
primary_group,
@@ -427,6 +428,7 @@ async def test_new_project(
427428

428429
@pytest.mark.parametrize(*standard_user_role_response())
429430
async def test_new_project_from_template(
431+
mock_dynamic_scheduler: None,
430432
client: TestClient,
431433
logged_user: UserInfoDict,
432434
primary_group: dict[str, str],
@@ -453,6 +455,7 @@ async def test_new_project_from_template(
453455

454456
@pytest.mark.parametrize(*standard_user_role_response())
455457
async def test_new_project_from_other_study(
458+
mock_dynamic_scheduler: None,
456459
client: TestClient,
457460
logged_user: UserInfoDict,
458461
primary_group: dict[str, str],
@@ -482,6 +485,7 @@ async def test_new_project_from_other_study(
482485

483486
@pytest.mark.parametrize(*standard_user_role_response())
484487
async def test_new_project_from_template_with_body(
488+
mock_dynamic_scheduler: None,
485489
client: TestClient,
486490
logged_user: UserInfoDict,
487491
primary_group: dict[str, str],
@@ -536,6 +540,7 @@ async def test_new_project_from_template_with_body(
536540

537541
@pytest.mark.parametrize(*standard_user_role_response())
538542
async def test_new_template_from_project(
543+
mock_dynamic_scheduler: None,
539544
client: TestClient,
540545
logged_user: dict[str, Any],
541546
primary_group: dict[str, str],

services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers__clone.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async def _request_clone_project(client: TestClient, url: URL) -> ProjectGet:
5454

5555
@pytest.mark.parametrize(*standard_role_response(), ids=str)
5656
async def test_clone_project_user_permissions(
57+
mock_dynamic_scheduler: None,
5758
client: TestClient,
5859
logged_user: UserInfoDict,
5960
user_project: ProjectDict,
@@ -85,6 +86,7 @@ async def test_clone_project_user_permissions(
8586
[UserRole.USER],
8687
)
8788
async def test_clone_project(
89+
mock_dynamic_scheduler: None,
8890
client: TestClient,
8991
logged_user: UserInfoDict,
9092
user_project: ProjectDict,

services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers__clone_in_workspace_and_folder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
# pylint: disable=unused-argument
44
# pylint: disable=unused-variable
55

6+
from collections.abc import Iterator
67
from copy import deepcopy
7-
from typing import Any, Iterator
8+
from typing import Any
89

910
import pytest
1011
import sqlalchemy as sa
@@ -88,6 +89,7 @@ async def _request_clone_project(client: TestClient, url: URL) -> ProjectGet:
8889
[UserRole.USER],
8990
)
9091
async def test_clone_project(
92+
mock_dynamic_scheduler: None,
9193
client: TestClient,
9294
logged_user: UserInfoDict,
9395
user_project: ProjectDict,

services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers__delete.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
# pylint: disable=unused-variable
66

77

8-
from collections.abc import Callable, Iterator
8+
from collections.abc import Awaitable, Callable, Iterator
99
from http import HTTPStatus
10-
from typing import Awaitable
1110
from unittest import mock
1211
from unittest.mock import MagicMock, call
1312

services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers__list.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ async def test_list_projects_with_invalid_pagination_parameters(
152152
@pytest.mark.parametrize("limit", [7, 20, 43])
153153
@pytest.mark.parametrize(*standard_user_role())
154154
async def test_list_projects_with_pagination(
155+
mock_dynamic_scheduler: None,
155156
client: TestClient,
156157
logged_user: dict[str, Any],
157158
primary_group: dict[str, str],
@@ -181,17 +182,17 @@ async def test_list_projects_with_pagination(
181182
next_link = None
182183
default_query_parameter = {"limit": limit}
183184
projects = []
184-
for i in range(NUMBER_OF_CALLS):
185+
for _ in range(NUMBER_OF_CALLS):
185186
print(
186187
"calling in with query",
187188
next_link.query if next_link else default_query_parameter,
188189
)
189190
data, meta, links = await _list_projects(
190191
client,
191192
expected.ok,
192-
query_parameters=next_link.query
193-
if next_link
194-
else default_query_parameter,
193+
query_parameters=(
194+
next_link.query if next_link else default_query_parameter
195+
),
195196
)
196197
print("...received [", meta, "]")
197198
assert len(data) == meta["count"]

services/web/server/tests/unit/with_dbs/02/test_projects_metadata_handlers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ async def _wait_until_deleted():
114114

115115
@pytest.mark.parametrize(*standard_user_role_response())
116116
async def test_new_project_with_parent_project_node(
117+
mock_dynamic_scheduler: None,
117118
# for deletion
118119
mocked_dynamic_services_interface: dict[str, MagicMock],
119120
storage_subsystem_mock: MockedStorageSubsystem,
@@ -191,6 +192,7 @@ async def test_new_project_with_parent_project_node(
191192

192193
@pytest.mark.parametrize(*standard_user_role_response())
193194
async def test_new_project_with_invalid_parent_project_node(
195+
mock_dynamic_scheduler: None,
194196
# for deletion
195197
mocked_dynamic_services_interface: dict[str, MagicMock],
196198
storage_subsystem_mock: MockedStorageSubsystem,
@@ -274,6 +276,7 @@ async def test_new_project_with_invalid_parent_project_node(
274276

275277
@pytest.mark.parametrize(*standard_user_role_response())
276278
async def test_set_project_parent_backward_compatibility(
279+
mock_dynamic_scheduler: None,
277280
# for deletion
278281
mocked_dynamic_services_interface: dict[str, MagicMock],
279282
storage_subsystem_mock: MockedStorageSubsystem,
@@ -393,6 +396,7 @@ async def test_update_project_metadata_backward_compatibility_with_same_project_
393396

394397
@pytest.mark.parametrize(*standard_user_role_response())
395398
async def test_update_project_metadata_s4lacad_backward_compatibility_passing_nil_parent_node_id(
399+
mock_dynamic_scheduler: None,
396400
# for deletion
397401
mocked_dynamic_services_interface: dict[str, MagicMock],
398402
storage_subsystem_mock: MockedStorageSubsystem,

services/web/server/tests/unit/with_dbs/02/test_projects_nodes_handler.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ async def test_create_node_returns_422_if_body_is_missing(
318318
)
319319
@pytest.mark.parametrize(*standard_role_response(), ids=str)
320320
async def test_create_node(
321+
mock_dynamic_scheduler: None,
321322
node_class: str,
322323
expect_run_service_call: bool,
323324
client: TestClient,
@@ -376,6 +377,7 @@ def standard_user_role() -> tuple[str, tuple]:
376377

377378
@pytest.mark.parametrize(*standard_user_role())
378379
async def test_create_and_delete_many_nodes_in_parallel(
380+
mock_dynamic_scheduler: None,
379381
disable_max_number_of_running_dynamic_nodes: dict[str, str],
380382
client: TestClient,
381383
user_project: ProjectDict,
@@ -395,8 +397,8 @@ class _RunningServices:
395397
running_services_uuids: list[str] = field(default_factory=list)
396398

397399
def num_services(
398-
self, *args, **kwargs
399-
) -> list[DynamicServiceGet]: # noqa: ARG002
400+
self, *args, **kwargs # noqa: ARG002
401+
) -> list[DynamicServiceGet]:
400402
return [
401403
DynamicServiceGet.model_validate(
402404
DynamicServiceGet.model_config["json_schema_extra"]["examples"][1]
@@ -470,6 +472,7 @@ def inc_running_services(self, *args, **kwargs): # noqa: ARG002
470472

471473
@pytest.mark.parametrize(*standard_user_role())
472474
async def test_create_node_does_not_start_dynamic_node_if_there_are_already_too_many_running(
475+
mock_dynamic_scheduler: None,
473476
client: TestClient,
474477
user_project_with_num_dynamic_services: Callable[[int], Awaitable[ProjectDict]],
475478
expected: ExpectedResponse,
@@ -503,6 +506,7 @@ async def test_create_node_does_not_start_dynamic_node_if_there_are_already_too_
503506

504507
@pytest.mark.parametrize(*standard_user_role())
505508
async def test_create_many_nodes_in_parallel_still_is_limited_to_the_defined_maximum(
509+
mock_dynamic_scheduler: None,
506510
client: TestClient,
507511
user_project_with_num_dynamic_services: Callable[[int], Awaitable[ProjectDict]],
508512
expected: ExpectedResponse,
@@ -524,8 +528,8 @@ class _RunninServices:
524528
running_services_uuids: list[str] = field(default_factory=list)
525529

526530
async def num_services(
527-
self, *args, **kwargs
528-
) -> list[dict[str, Any]]: # noqa: ARG002
531+
self, *args, **kwargs # noqa: ARG002
532+
) -> list[dict[str, Any]]:
529533
return [
530534
{"service_uuid": service_uuid}
531535
for service_uuid in self.running_services_uuids
@@ -588,6 +592,7 @@ async def inc_running_services(self, *args, **kwargs): # noqa: ARG002
588592

589593
@pytest.mark.parametrize(*standard_user_role())
590594
async def test_create_node_does_start_dynamic_node_if_max_num_set_to_0(
595+
mock_dynamic_scheduler: None,
591596
disable_max_number_of_running_dynamic_nodes: dict[str, str],
592597
client: TestClient,
593598
user_project_with_num_dynamic_services: Callable[[int], Awaitable[ProjectDict]],
@@ -625,6 +630,7 @@ async def test_create_node_does_start_dynamic_node_if_max_num_set_to_0(
625630
)
626631
@pytest.mark.parametrize(*standard_role_response(), ids=str)
627632
async def test_creating_deprecated_node_returns_406_not_acceptable(
633+
mock_dynamic_scheduler: None,
628634
client: TestClient,
629635
user_project: ProjectDict,
630636
expected: ExpectedResponse,
@@ -664,6 +670,7 @@ async def test_creating_deprecated_node_returns_406_not_acceptable(
664670
)
665671
@pytest.mark.parametrize(*standard_role_response(), ids=str)
666672
async def test_delete_node(
673+
mock_dynamic_scheduler: None,
667674
client: TestClient,
668675
logged_user: dict,
669676
user_project: ProjectDict,

services/web/server/tests/unit/with_dbs/02/test_projects_nodes_handlers__patch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def mock_catalog_rpc_check_for_service(mocker: MockerFixture):
6565
],
6666
)
6767
async def test_patch_project_node_entrypoint_access(
68+
mock_dynamic_scheduler: None,
6869
client: TestClient,
6970
logged_user: UserInfoDict,
7071
user_project: ProjectDict,
@@ -86,6 +87,7 @@ async def test_patch_project_node_entrypoint_access(
8687
"user_role,expected", [(UserRole.USER, status.HTTP_204_NO_CONTENT)]
8788
)
8889
async def test_patch_project_node(
90+
mock_dynamic_scheduler: None,
8991
client: TestClient,
9092
logged_user: UserInfoDict,
9193
user_project: ProjectDict,

0 commit comments

Comments
 (0)