From 16551d923088c50ae54a5da1c34cf1bbeda08b17 Mon Sep 17 00:00:00 2001 From: Renn F Date: Wed, 21 Oct 2026 06:00:23 +0200 Subject: [PATCH 1/2] fix(docker): make the compose test path pass without a lockfile or a localhost Redis --- Dockerfile | 2 +- compose.yml | 1 - tests/test_adapter_django.py | 1 + tests/test_adapter_flask.py | 2 ++ tests/test_logging_utils.py | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d94c3bf..6a99778 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN pip install uv COPY pyproject.toml uv.lock* README.md /app/ -RUN uv sync --extra dev --frozen +RUN uv sync --extra dev ENV PATH="/app/.venv/bin:$PATH" diff --git a/compose.yml b/compose.yml index 7aae9d6..004bd5f 100644 --- a/compose.yml +++ b/compose.yml @@ -14,7 +14,6 @@ services: - ./guard_agent:/app/guard_agent:z - ./tests:/app/tests:z - ./pyproject.toml:/app/pyproject.toml:z - - ./uv.lock:/app/uv.lock:z depends_on: redis: condition: service_started diff --git a/tests/test_adapter_django.py b/tests/test_adapter_django.py index b6860ef..4c18d6a 100644 --- a/tests/test_adapter_django.py +++ b/tests/test_adapter_django.py @@ -16,6 +16,7 @@ agent_api_key=API_KEY, agent_project_id=PROJECT_ID, passive_mode=True, + enable_redis=False, ) diff --git a/tests/test_adapter_flask.py b/tests/test_adapter_flask.py index c6c7504..fc7458e 100644 --- a/tests/test_adapter_flask.py +++ b/tests/test_adapter_flask.py @@ -46,6 +46,7 @@ def _build_app(self) -> Flask: agent_api_key=self.API_KEY, agent_project_id=self.PROJECT_ID, passive_mode=True, + enable_redis=False, ) FlaskAPIGuard(app, config=config) @@ -87,6 +88,7 @@ def test_deferred_init_app_pattern(self) -> None: agent_api_key=self.API_KEY, agent_project_id=self.PROJECT_ID, passive_mode=True, + enable_redis=False, ) guard = FlaskAPIGuard() app = Flask(__name__) diff --git a/tests/test_logging_utils.py b/tests/test_logging_utils.py index 7c7bafa..e656c58 100644 --- a/tests/test_logging_utils.py +++ b/tests/test_logging_utils.py @@ -214,7 +214,7 @@ def test_console_handler_emits_only_without_host_handlers(self) -> None: try: setup_agent_logging() handler = logging.getLogger(GUARD_AGENT_LOGGER_NAME).handlers[0] - assert handler.filter(make_record()) is True + assert handler.filter(make_record()) finally: root.handlers = original_handlers From b016cd5c54a4c61519bb2ef30376539909ac0451 Mon Sep 17 00:00:00 2001 From: Renn F Date: Wed, 21 Oct 2026 06:14:32 +0200 Subject: [PATCH 2/2] fix(tests): keep Redis on in the adapter smoke tests and read its URL from REDIS_URL --- tests/test_adapter_django.py | 5 ++++- tests/test_adapter_flask.py | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_adapter_django.py b/tests/test_adapter_django.py index 4c18d6a..accd4a5 100644 --- a/tests/test_adapter_django.py +++ b/tests/test_adapter_django.py @@ -1,5 +1,7 @@ from __future__ import annotations +import os + from django.conf import settings from django.http import HttpRequest, JsonResponse from django.test import Client @@ -10,13 +12,14 @@ API_KEY = "test-api-key-1234567890" PROJECT_ID = "test-project" +REDIS_URL = os.getenv("REDIS_URL") or "redis://localhost:6379" settings.GUARD_SECURITY_CONFIG = SecurityConfig( enable_agent=True, agent_api_key=API_KEY, agent_project_id=PROJECT_ID, passive_mode=True, - enable_redis=False, + redis_url=REDIS_URL, ) diff --git a/tests/test_adapter_flask.py b/tests/test_adapter_flask.py index fc7458e..a4cbc26 100644 --- a/tests/test_adapter_flask.py +++ b/tests/test_adapter_flask.py @@ -11,6 +11,7 @@ unit tests for ``guard_agent/client.py``. """ +import os import warnings import pytest @@ -20,6 +21,8 @@ from guard_agent.models import AgentConfig +REDIS_URL = os.getenv("REDIS_URL") or "redis://localhost:6379" + pytestmark = pytest.mark.filterwarnings( "ignore:coroutine .* was never awaited:RuntimeWarning" ) @@ -46,7 +49,7 @@ def _build_app(self) -> Flask: agent_api_key=self.API_KEY, agent_project_id=self.PROJECT_ID, passive_mode=True, - enable_redis=False, + redis_url=REDIS_URL, ) FlaskAPIGuard(app, config=config) @@ -88,7 +91,7 @@ def test_deferred_init_app_pattern(self) -> None: agent_api_key=self.API_KEY, agent_project_id=self.PROJECT_ID, passive_mode=True, - enable_redis=False, + redis_url=REDIS_URL, ) guard = FlaskAPIGuard() app = Flask(__name__)