From 0315a42be6bbac0e10da6cddb365980225917d8c Mon Sep 17 00:00:00 2001 From: gabrii Date: Thu, 18 Sep 2025 08:36:16 +0200 Subject: [PATCH] Test configuration --- app/azure/response_adapter.py | 3 --- tests/test_functional.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/azure/response_adapter.py b/app/azure/response_adapter.py index 13b60c0..7dfdeba 100644 --- a/app/azure/response_adapter.py +++ b/app/azure/response_adapter.py @@ -190,9 +190,6 @@ class ResponseAdapter: for ev in sse_to_events( upstream_resp.iter_content(chunk_size=8192) ): - if ev.is_done: - # Upstream [DONE] sentinel - continue handler_name = "_" + (ev.event or "").replace( "response.", "" ).replace(".", "__") diff --git a/tests/test_functional.py b/tests/test_functional.py index 261ac60..4490351 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -3,6 +3,8 @@ See: http://webtest.readthedocs.org/ """ +import environs + class TestConfig: """Config.""" @@ -13,6 +15,21 @@ class TestConfig: assert app.config["AZURE_BASE_URL"] != "change_me" assert app.config["AZURE_API_KEY"] != "change_me" + def test_default_settings_load(self, monkeypatch): + """Patch Env.read_env to read from .env.example and import settings.""" + orig_read_env = environs.Env.read_env + monkeypatch.setattr( + environs.Env, + "read_env", + lambda *args, **kwargs: orig_read_env( + ".env.example", override=True, **kwargs + ), + ) + + from app import settings + + assert settings.AZURE_BASE_URL == "https://change-me.openai.azure.com" + class TestModels: """Models.""" @@ -21,6 +38,19 @@ class TestModels: """Ensure /models endpoint returns HTTP 400.""" testapp.get("/models", status=400) + def test_models_endpoint_returns_200(self, testapp): + """Ensure /models endpoint returns HTTP 400.""" + response = testapp.get( + "/models", + status=200, + headers={"Authorization": "Bearer test-service-api-key"}, + ) + content = response.body.decode("utf-8") + assert '"gpt-high"' in content + assert '"gpt-medium"' in content + assert '"gpt-low"' in content + assert '"gpt-minimal"' in content + def test_health_endpoint_returns_200(self, testapp): """Ensure /health endpoint returns HTTP 200.""" testapp.get("/health", status=200)