From e61ece9340d434b30aba566a189a7e3ef39bec0f Mon Sep 17 00:00:00 2001 From: Pedro Crespo <32402063+pcrespov@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:21:54 +0200 Subject: [PATCH] fixes deletion in test --- .../with_dbs/02/test_projects_handlers__delete.py | 9 +++++---- .../02/test_projects_metadata_handlers.py | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/services/web/server/tests/unit/with_dbs/02/test_projects_handlers__delete.py b/services/web/server/tests/unit/with_dbs/02/test_projects_handlers__delete.py index 046471c4f51a..8a0d74892261 100644 --- a/services/web/server/tests/unit/with_dbs/02/test_projects_handlers__delete.py +++ b/services/web/server/tests/unit/with_dbs/02/test_projects_handlers__delete.py @@ -4,7 +4,8 @@ # pylint: disable=too-many-arguments -from typing import Any, Callable, Iterator +from collections.abc import Callable, Iterator +from typing import Any from unittest import mock from unittest.mock import MagicMock, call @@ -129,11 +130,11 @@ async def test_delete_multiple_opened_project_forbidden( redis_client, ): # service in project - service = await create_dynamic_service_mock(logged_user["id"], user_project["uuid"]) + await create_dynamic_service_mock(logged_user["id"], user_project["uuid"]) # open project in tab1 client_session_id1 = client_session_id_factory() try: - sio1 = await socketio_client_factory(client_session_id1) + await socketio_client_factory(client_session_id1) except SocketConnectionError: if user_role != UserRole.ANONYMOUS: pytest.fail("socket io connection should not fail") @@ -151,7 +152,7 @@ async def test_delete_multiple_opened_project_forbidden( # delete project in tab2 client_session_id2 = client_session_id_factory() try: - sio2 = await socketio_client_factory(client_session_id2) + await socketio_client_factory(client_session_id2) except SocketConnectionError: if user_role != UserRole.ANONYMOUS: pytest.fail("socket io connection should not fail") diff --git a/services/web/server/tests/unit/with_dbs/02/test_projects_metadata_handlers.py b/services/web/server/tests/unit/with_dbs/02/test_projects_metadata_handlers.py index 61b4aa1f7928..9a2834128177 100644 --- a/services/web/server/tests/unit/with_dbs/02/test_projects_metadata_handlers.py +++ b/services/web/server/tests/unit/with_dbs/02/test_projects_metadata_handlers.py @@ -16,7 +16,9 @@ from pydantic import parse_obj_as from pytest_simcore.helpers.utils_assert import assert_status from pytest_simcore.helpers.utils_login import UserInfoDict +from pytest_simcore.helpers.utils_webserver_unit_with_db import MockedStorageSubsystem from simcore_postgres_database.models.users import UserRole +from simcore_service_webserver.projects import _crud_delete_utils from simcore_service_webserver.projects.models import ProjectDict @@ -27,7 +29,10 @@ ], ) async def test_custom_metadata_handlers( - mocked_director_v2_api: None, # for deletion + # for deletion + mocked_director_v2_api: None, + storage_subsystem_mock: MockedStorageSubsystem, + # client: TestClient, faker: Faker, logged_user: UserInfoDict, @@ -79,6 +84,14 @@ async def test_custom_metadata_handlers( response = await client.delete(f"{url}") await assert_status(response, expected_cls=web.HTTPNoContent) + async def _wait_until_deleted(): + tasks = _crud_delete_utils.get_scheduled_tasks( + project_uuid=user_project["uuid"], user_id=logged_user["id"] + ) + await tasks[0] + + await _wait_until_deleted() + # no metadata -> project not found url = client.app.router["get_project_custom_metadata"].url_for( project_id=user_project["uuid"]