Skip to content

Commit

Permalink
fixes director_V2_service_responses_mok
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Mar 2, 2022
1 parent b6cc73a commit a944020
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions services/web/server/tests/integration/01/test_garbage_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
WAIT_FOR_COMPLETE_GC_CYCLE = GARBAGE_COLLECTOR_INTERVAL + SERVICE_DELETION_DELAY + 2


# FIXTURES ----------------------------------------------------------------------------------


@pytest.fixture(autouse=True)
def __drop_and_recreate_postgres__(database_from_template_before_each_function) -> None:
yield
Expand All @@ -79,11 +82,15 @@ async def __delete_all_redis_keys__(redis_settings: RedisSettings):
# do nothing on teadown


@pytest.fixture
@pytest.fixture(autouse=True)
async def director_v2_service_responses_mock(
director_v2_service_responses_mock: AioResponsesMock,
) -> AsyncIterable[AioResponsesMock]:
# OVERRIDES pytest_simcore.aioreposnse_mocker.director_v2_service_responses_mock and appends
# NOTE: auto-mock under this test-suite module is justified since
# directorv2 service is not included in pytest_simcore_core_services_selection
# All requests to director-v2 service are intercepted and responses are patched
# as defined in director_v2_service_responses_mock

get_computation_pattern = re.compile(
r"^http://[a-z\-_]*director-v2:[0-9]+/v2/computations/.*$"
Expand Down Expand Up @@ -154,7 +161,17 @@ def client(
)


################ utils
@pytest.fixture
def disable_garbage_collector_background_task(mocker):
"""patch the setup of the garbage collector so we can call it manually"""
mocker.patch(
"simcore_service_webserver.garbage_collector.setup_garbage_collector",
autospec=True,
return_value="",
)


# UTILS ----------------------------------------------------------------------------------


async def login_user(client: TestClient):
Expand Down Expand Up @@ -370,20 +387,11 @@ async def assert_one_owner_for_project(
return True


################ end utils


@pytest.fixture
def mock_garbage_collector_task(mocker):
"""patch the setup of the garbage collector so we can call it manually"""
mocker.patch(
"simcore_service_webserver.garbage_collector.setup_garbage_collector",
return_value="",
)
# TESTS ---------------------------------------------------------------------------


async def test_t1_while_guest_is_connected_no_resources_are_removed(
mock_garbage_collector_task,
disable_garbage_collector_background_task,
client,
socketio_client_factory: Callable,
aiopg_engine,
Expand All @@ -409,7 +417,7 @@ async def test_t1_while_guest_is_connected_no_resources_are_removed(


async def test_t2_cleanup_resources_after_browser_is_closed(
mock_garbage_collector_task,
disable_garbage_collector_background_task,
simcore_services_ready,
client,
socketio_client_factory: Callable,
Expand Down

0 comments on commit a944020

Please sign in to comment.