From 4ad836707de650ff7128f675934458707c53b496 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:43:52 +0100 Subject: [PATCH] disable auto-caching for test --- .../src/simcore_service_director/registry_proxy.py | 13 +++++++++---- services/director/tests/unit/test_registry_proxy.py | 10 ++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/services/director/src/simcore_service_director/registry_proxy.py b/services/director/src/simcore_service_director/registry_proxy.py index 216d8e4b5223..a1adfe977a0d 100644 --- a/services/director/src/simcore_service_director/registry_proxy.py +++ b/services/director/src/simcore_service_director/registry_proxy.py @@ -318,6 +318,7 @@ async def list_image_tags_gen( tags, headers = await registry_request( app, path=path, method="GET", use_cache=not update_cache ) # initial call + assert "tags" in tags # nosec while True: if "Link" in headers: next_path = ( @@ -331,11 +332,15 @@ async def list_image_tags_gen( else: prefetch_task = None - yield list( - filter( - VERSION_REG.match, - tags["tags"], + yield ( + list( + filter( + VERSION_REG.match, + tags["tags"], + ) ) + if tags["tags"] is not None + else [] ) if prefetch_task: tags, headers = await prefetch_task diff --git a/services/director/tests/unit/test_registry_proxy.py b/services/director/tests/unit/test_registry_proxy.py index 7861179323c5..538e4220f0d4 100644 --- a/services/director/tests/unit/test_registry_proxy.py +++ b/services/director/tests/unit/test_registry_proxy.py @@ -4,10 +4,12 @@ import asyncio import json import time +from unittest import mock import pytest from fastapi import FastAPI from pytest_benchmark.plugin import BenchmarkFixture +from pytest_mock.plugin import MockerFixture from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict from pytest_simcore.helpers.typing_env import EnvVarsDict from settings_library.docker_registry import RegistrySettings @@ -228,9 +230,17 @@ def configure_registry_caching( ) +@pytest.fixture +def with_disabled_auto_caching(mocker: MockerFixture) -> mock.Mock: + return mocker.patch( + "simcore_service_director.registry_proxy._list_all_services_task", autospec=True + ) + + async def test_registry_caching( configure_registry_access: EnvVarsDict, configure_registry_caching: EnvVarsDict, + with_disabled_auto_caching: mock.Mock, app_settings: ApplicationSettings, app: FastAPI, push_services,