Test configuration
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user