"""L1 API core: liveness/readiness probes and the dashboard bootstrap config. Drives the real app through ``httpx.ASGITransport`` (no lifespan), so the ``_stopping`` flag is flipped by hand the same way SIGTERM does at runtime. """ import pytest pytestmark = pytest.mark.e2e async def test_health_is_ok(client): resp = await client.get("/health") assert resp.status_code == 200 assert resp.json() == {"status": "ok"} async def test_health_ready_when_running(client, app_state): app_state.app._stopping = False resp = await client.get("/health/ready") assert resp.status_code == 200 assert resp.json() == {"status": "ready"} async def test_health_ready_is_503_while_stopping(client, app_state, monkeypatch): monkeypatch.setattr(app_state.app, "_stopping", True) resp = await client.get("/health/ready") assert resp.status_code == 503 assert resp.json() == {"status": "stopping"} async def test_config_youtube_enabled(client, app_state, monkeypatch): monkeypatch.setattr(app_state.app, "DISABLE_YOUTUBE_URL", False) monkeypatch.delenv("LLM_BASE_URL", raising=False) monkeypatch.delenv("LLM_PROVIDER", raising=False) resp = await client.get("/api/config") assert resp.status_code == 200 body = resp.json() assert body["youtubeUrlEnabled"] is True assert body["billingEnabled"] is False assert body["jobRetentionSeconds"] == app_state.app.JOB_RETENTION_SECONDS # No OpenAI-compatible server configured -> the dashboard is told nothing. assert body["localLlm"] is None async def test_config_youtube_disabled(client, app_state, monkeypatch): monkeypatch.setattr(app_state.app, "DISABLE_YOUTUBE_URL", True) resp = await client.get("/api/config") assert resp.status_code == 200 assert resp.json()["youtubeUrlEnabled"] is False async def test_config_describes_local_llm(client, app_state, monkeypatch): monkeypatch.setenv("LLM_PROVIDER", "openai") monkeypatch.setenv("LLM_BASE_URL", "http://127.0.0.1:11434") monkeypatch.delenv("LLM_MODEL", raising=False) resp = await client.get("/api/config") assert resp.status_code == 200 assert resp.json()["localLlm"] == { "provider": "openai", "model": "llama3.1:8b", "baseUrl": "http://127.0.0.1:11434", }