discovery-by-llm/backend/tests/test_health.py
Justin Visser cdace7d170
Some checks are pending
ci / backend (push) Waiting to run
ci / frontend (push) Waiting to run
fix: type the health test mode, pace cards with the stream, and size the results panel
2026-08-11 10:15:20 +02:00

35 lines
1.1 KiB
Python

"""Smoke test for the application factory."""
from unittest.mock import AsyncMock, Mock
import pytest
from fastapi.testclient import TestClient
from app.config import AppMode, Settings
from app.main import create_app
def test_health_reports_mode() -> None:
client = TestClient(create_app())
response = client.get("/api/health")
assert response.status_code == 200
assert response.json()["mode"] in ("live", "demo")
def test_anthropic_client_uses_configured_timeout(monkeypatch: pytest.MonkeyPatch) -> None:
anthropic_client = Mock()
anthropic_client.close = AsyncMock()
constructor = Mock(return_value=anthropic_client)
monkeypatch.setattr("app.main.AsyncAnthropic", constructor)
live_settings = Settings(
app_mode=AppMode.LIVE,
spotify_client_id="client-id",
anthropic_api_key="api-key",
llm_timeout_seconds=42.0,
)
with TestClient(create_app(live_settings)) as client:
response = client.get("/api/health")
assert response.status_code == 200
constructor.assert_called_once_with(api_key="api-key", timeout=42.0, http_client=None)