Test configuration

This commit is contained in:
gabrii
2025-09-18 08:36:16 +02:00
parent 933567edc0
commit 0315a42be6
2 changed files with 30 additions and 3 deletions
-3
View File
@@ -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(".", "__")
+30
View File
@@ -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)