Skip to content

Commit a37613b

Browse files
fix tests
1 parent e021706 commit a37613b

13 files changed

+0
-169
lines changed

services/web/server/src/simcore_service_webserver/projects/utils.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -189,42 +189,6 @@ def is_graph_equal(
189189
return True
190190

191191

192-
def are_project_services_available(
193-
project: dict[str, Any], available_services: list[dict[str, str]]
194-
) -> bool:
195-
if not project["workbench"]:
196-
# empty project
197-
return True
198-
199-
# list services in project
200-
needed_services = {
201-
(srv["key"], srv["version"]) for _, srv in project["workbench"].items()
202-
}
203-
204-
# list available services
205-
available_services_set = {
206-
(srv["key"], srv["version"]) for srv in available_services
207-
}
208-
209-
return needed_services.issubset(available_services_set)
210-
211-
212-
def get_project_unavailable_services(
213-
project: dict[str, Any], available_services: list[dict[str, Any]]
214-
) -> set[tuple[str, str]]:
215-
# get project services
216-
required: set[tuple[str, str]] = {
217-
(s["key"], s["version"]) for _, s in project["workbench"].items()
218-
}
219-
220-
# get available services
221-
available: set[tuple[str, str]] = {
222-
(s["key"], s["version"]) for s in available_services
223-
}
224-
225-
return required - available
226-
227-
228192
def extract_dns_without_default_port(url: URL) -> str:
229193
port = "" if url.port == 80 else f":{url.port}"
230194
return f"{url.host}{port}"

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from models_library.projects import ProjectID, ProjectTemplateType
2020
from models_library.users import UserID
2121
from pydantic import BaseModel, PositiveInt
22-
from pytest_mock import MockerFixture
2322
from pytest_simcore.helpers.assert_checks import assert_status
2423
from pytest_simcore.helpers.webserver_login import UserInfoDict
2524
from pytest_simcore.helpers.webserver_parametrizations import (
@@ -53,15 +52,6 @@ def standard_and_tester_user_roles() -> tuple[str, tuple[UserRole, ExpectedRespo
5352
)
5453

5554

56-
@pytest.fixture
57-
def mock_catalog_api_get_services_for_user_in_product(mocker: MockerFixture):
58-
mocker.patch(
59-
"simcore_service_webserver.projects._crud_api_read.catalog_service.get_services_for_user_in_product",
60-
spec=True,
61-
return_value=[],
62-
)
63-
64-
6555
async def _new_project(
6656
client: TestClient,
6757
user_id: UserID,
@@ -119,7 +109,6 @@ async def test_list_projects_with_search_parameter(
119109
tests_data_dir: Path,
120110
osparc_product_name: str,
121111
project_db_cleaner: None,
122-
mock_catalog_api_get_services_for_user_in_product,
123112
):
124113
projects_info = [
125114
_ProjectInfo(
@@ -309,7 +298,6 @@ async def test_list_projects_with_order_by_parameter(
309298
tests_data_dir: Path,
310299
osparc_product_name: str,
311300
project_db_cleaner: None,
312-
mock_catalog_api_get_services_for_user_in_product: None,
313301
):
314302
projects_info = [
315303
_ProjectInfo(
@@ -449,7 +437,6 @@ async def test_list_projects_for_specific_folder_id(
449437
tests_data_dir: Path,
450438
osparc_product_name: str,
451439
project_db_cleaner: None,
452-
mock_catalog_api_get_services_for_user_in_product: None,
453440
setup_folders_db: FolderID,
454441
):
455442
projects_info = [
@@ -532,7 +519,6 @@ async def test_list_and_patch_projects_with_template_type(
532519
tests_data_dir: Path,
533520
osparc_product_name: str,
534521
project_db_cleaner: None,
535-
mock_catalog_api_get_services_for_user_in_product,
536522
):
537523
projects_type = [
538524
"STANDARD",

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import pytest
1313
from aiohttp.test_utils import TestClient
14-
from pytest_mock.plugin import MockerFixture
1514
from pytest_simcore.helpers.assert_checks import assert_status
1615
from pytest_simcore.helpers.webserver_login import UserInfoDict
1716
from servicelib.aiohttp import status
@@ -22,24 +21,6 @@
2221
API_PREFIX = "/" + api_version_prefix
2322

2423

25-
@pytest.fixture
26-
def mock_catalog_api_get_services_for_user_in_product(mocker: MockerFixture):
27-
mocker.patch(
28-
"simcore_service_webserver.projects._controller.projects_rest.catalog_service.get_services_for_user_in_product",
29-
spec=True,
30-
return_value=[],
31-
)
32-
33-
34-
@pytest.fixture
35-
def mock_are_project_services_available(mocker: MockerFixture):
36-
mocker.patch(
37-
"simcore_service_webserver.projects._controller.projects_rest.are_project_services_available",
38-
spec=True,
39-
return_value=True,
40-
)
41-
42-
4324
@pytest.mark.parametrize(
4425
"user_role,expected",
4526
[
@@ -81,8 +62,6 @@ async def test_patch_project(
8162
logged_user: UserInfoDict,
8263
user_project: ProjectDict,
8364
expected: HTTPStatus,
84-
mock_catalog_api_get_services_for_user_in_product,
85-
mock_are_project_services_available,
8665
):
8766
assert client.app
8867
base_url = client.app.router["patch_project"].url_for(

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,13 @@
1212
from models_library.api_schemas_webserver.projects_access_rights import (
1313
ProjectShareAccepted,
1414
)
15-
from pytest_mock import MockType
16-
from pytest_mock.plugin import MockerFixture
1715
from pytest_simcore.helpers.assert_checks import assert_status
1816
from pytest_simcore.helpers.webserver_login import NewUser, UserInfoDict
1917
from servicelib.aiohttp import status
2018
from simcore_service_webserver.db.models import UserRole
2119
from simcore_service_webserver.projects.models import ProjectDict
2220

2321

24-
@pytest.fixture
25-
def mock_catalog_api_get_services_for_user_in_product(
26-
mocker: MockerFixture,
27-
) -> MockType:
28-
return mocker.patch(
29-
"simcore_service_webserver.projects._controller.projects_rest.catalog_service.get_services_for_user_in_product",
30-
spec=True,
31-
return_value=[],
32-
)
33-
34-
35-
@pytest.fixture
36-
def mock_are_project_services_available(mocker: MockerFixture) -> MockType:
37-
return mocker.patch(
38-
"simcore_service_webserver.projects._controller.projects_rest.are_project_services_available",
39-
spec=True,
40-
return_value=True,
41-
)
42-
43-
4422
@pytest.mark.acceptance_test(
4523
"Driving test for https://github.com/ITISFoundation/osparc-issues/issues/1547"
4624
)
@@ -50,8 +28,6 @@ async def test_projects_groups_full_workflow( # noqa: PLR0915
5028
logged_user: UserInfoDict,
5129
user_project: ProjectDict,
5230
expected: HTTPStatus,
53-
mock_catalog_api_get_services_for_user_in_product: MockType,
54-
mock_are_project_services_available: MockType,
5531
):
5632
assert client.app
5733
# check the default project permissions
@@ -264,8 +240,6 @@ async def test_share_project(
264240
client: TestClient,
265241
logged_user: UserInfoDict,
266242
user_project: ProjectDict,
267-
mock_catalog_api_get_services_for_user_in_product: MockType,
268-
mock_are_project_services_available: MockType,
269243
):
270244
assert client.app
271245

@@ -332,8 +306,6 @@ async def test_share_project_with_roles(
332306
client: TestClient,
333307
logged_user: UserInfoDict,
334308
user_project: ProjectDict,
335-
mock_catalog_api_get_services_for_user_in_product: MockType,
336-
mock_are_project_services_available: MockType,
337309
user_role: UserRole,
338310
expected_status: HTTPStatus,
339311
):

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@
2626
API_PREFIX = "/" + api_version_prefix
2727

2828

29-
@pytest.fixture
30-
def mock_catalog_api_get_services_for_user_in_product(mocker: MockerFixture):
31-
mocker.patch(
32-
"simcore_service_webserver.projects._controller.projects_rest.catalog_service.get_services_for_user_in_product",
33-
spec=True,
34-
return_value=[],
35-
)
36-
37-
38-
@pytest.fixture
39-
def mock_are_project_services_available(mocker: MockerFixture):
40-
mocker.patch(
41-
"simcore_service_webserver.projects._controller.projects_rest.are_project_services_available",
42-
spec=True,
43-
return_value=True,
44-
)
45-
46-
4729
@pytest.fixture
4830
def mock_catalog_rpc_check_for_service(mocker: MockerFixture):
4931
mocker.patch(
@@ -99,8 +81,6 @@ async def test_patch_project_node(
9981
logged_user: UserInfoDict,
10082
user_project: ProjectDict,
10183
expected: HTTPStatus,
102-
mock_catalog_api_get_services_for_user_in_product: None,
103-
mock_are_project_services_available: None,
10484
mock_catalog_rpc_check_for_service: None,
10585
):
10686
node_id = next(iter(user_project["workbench"]))
@@ -221,8 +201,6 @@ async def test_patch_project_node_notifies(
221201
logged_user: UserInfoDict,
222202
user_project: ProjectDict,
223203
expected: HTTPStatus,
224-
mock_catalog_api_get_services_for_user_in_product,
225-
mock_are_project_services_available,
226204
mock_catalog_rpc_check_for_service,
227205
mocked_notify_project_node_update,
228206
):
@@ -257,8 +235,6 @@ async def test_patch_project_node_inputs_notifies(
257235
logged_user: UserInfoDict,
258236
user_project: ProjectDict,
259237
expected: HTTPStatus,
260-
mock_catalog_api_get_services_for_user_in_product,
261-
mock_are_project_services_available,
262238
mocked_notify_project_node_update,
263239
):
264240
node_id = next(iter(user_project["workbench"]))
@@ -297,8 +273,6 @@ async def test_patch_project_node_inputs_with_data_type_change(
297273
logged_user: UserInfoDict,
298274
user_project: ProjectDict,
299275
expected: HTTPStatus,
300-
mock_catalog_api_get_services_for_user_in_product,
301-
mock_are_project_services_available,
302276
):
303277
node_id = next(iter(user_project["workbench"]))
304278
assert client.app
@@ -350,8 +324,6 @@ async def test_patch_project_node_service_key_with_error(
350324
logged_user: UserInfoDict,
351325
user_project: ProjectDict,
352326
expected: HTTPStatus,
353-
mock_catalog_api_get_services_for_user_in_product,
354-
mock_are_project_services_available,
355327
mocker: MockerFixture,
356328
):
357329
node_id = next(iter(user_project["workbench"]))

services/web/server/tests/unit/with_dbs/04/folders/test_folders.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,12 @@ async def test_project_folder_movement_full_workflow(
269269
await assert_status(resp, status.HTTP_204_NO_CONTENT)
270270

271271

272-
@pytest.fixture
273-
def mock_catalog_api_get_services_for_user_in_product(mocker: MockerFixture):
274-
mocker.patch(
275-
"simcore_service_webserver.projects._crud_api_read.catalog_service.get_services_for_user_in_product",
276-
spec=True,
277-
return_value=[],
278-
)
279-
280-
281272
@pytest.mark.parametrize("user_role,expected", [(UserRole.USER, status.HTTP_200_OK)])
282273
async def test_project_listing_inside_of_private_folder(
283274
client: TestClient,
284275
logged_user: UserInfoDict,
285276
user_project: ProjectDict,
286277
expected: HTTPStatus,
287-
mock_catalog_api_get_services_for_user_in_product: MockerFixture,
288278
):
289279
assert client.app
290280

@@ -404,7 +394,6 @@ async def test_folders_deletion(
404394
logged_user: UserInfoDict,
405395
user_project: ProjectDict,
406396
expected: HTTPStatus,
407-
mock_catalog_api_get_services_for_user_in_product: MockerFixture,
408397
mock_storage_delete_data_folders: mock.Mock,
409398
):
410399
assert client.app

services/web/server/tests/unit/with_dbs/04/workspaces/conftest.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import pytest
77
import sqlalchemy as sa
8-
from pytest_mock import MockerFixture
98
from simcore_postgres_database.models.projects import projects
109
from simcore_postgres_database.models.workspaces import workspaces
1110

@@ -16,17 +15,3 @@ def workspaces_clean_db(postgres_db: sa.engine.Engine) -> Iterator[None]:
1615
yield
1716
con.execute(workspaces.delete())
1817
con.execute(projects.delete())
19-
20-
21-
@pytest.fixture
22-
def mock_catalog_api_get_services_for_user_in_product(mocker: MockerFixture):
23-
mocker.patch(
24-
"simcore_service_webserver.projects._crud_api_read.catalog_service.get_services_for_user_in_product",
25-
spec=True,
26-
return_value=[],
27-
)
28-
mocker.patch(
29-
"simcore_service_webserver.projects._controller.projects_rest.are_project_services_available",
30-
spec=True,
31-
return_value=True,
32-
)

services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from aiohttp.test_utils import TestClient
1212
from models_library.api_schemas_webserver.workspaces import WorkspaceGet
1313
from models_library.rest_ordering import OrderDirection
14-
from pytest_mock import MockerFixture
1514
from pytest_simcore.helpers.assert_checks import assert_status
1615
from pytest_simcore.helpers.webserver_login import UserInfoDict
1716
from pytest_simcore.helpers.webserver_parametrizations import (
@@ -64,7 +63,6 @@ async def test_workspaces_workflow(
6463
logged_user: UserInfoDict,
6564
user_project: ProjectDict,
6665
expected: HTTPStatus,
67-
mock_catalog_api_get_services_for_user_in_product: MockerFixture,
6866
workspaces_clean_db: AsyncIterator[None],
6967
):
7068
assert client.app

services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces__delete_workspace_with_content.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ async def test_workspaces_full_workflow_deletion(
4747
logged_user: UserInfoDict,
4848
user_project: ProjectDict,
4949
expected: HTTPStatus,
50-
mock_catalog_api_get_services_for_user_in_product: MockerFixture,
5150
fake_project: ProjectDict,
5251
workspaces_clean_db: None,
5352
mock_storage_delete_data_folders: mock.Mock,

services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces__folders_and_projects_crud.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
2828
logged_user: UserInfoDict,
2929
user_project: ProjectDict,
3030
expected: HTTPStatus,
31-
mock_catalog_api_get_services_for_user_in_product: MockerFixture,
3231
fake_project: ProjectDict,
3332
workspaces_clean_db: None,
3433
):
@@ -257,7 +256,6 @@ async def test_workspaces_delete_folders(
257256
logged_user: UserInfoDict,
258257
user_project: ProjectDict,
259258
expected: HTTPStatus,
260-
mock_catalog_api_get_services_for_user_in_product: MockerFixture,
261259
fake_project: ProjectDict,
262260
workspaces_clean_db: None,
263261
mock_storage_delete_data_folders: mock.Mock,
@@ -367,7 +365,6 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
367365
logged_user: UserInfoDict,
368366
user_project: ProjectDict,
369367
expected: HTTPStatus,
370-
mock_catalog_api_get_services_for_user_in_product: MockerFixture,
371368
fake_project: ProjectDict,
372369
workspaces_clean_db: None,
373370
):

0 commit comments

Comments
 (0)