Skip to content

Commit

Permalink
fixes deletion in test
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Jul 6, 2023
1 parent 81ecd1b commit e61ece9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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,
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit e61ece9

Please sign in to comment.