"""Tests for the health endpoints (/health, /ready, /providers).""" from __future__ import annotations from typing import Generator import pytest from fastapi.testclient import TestClient @pytest.fixture def client() -> Generator[TestClient, None, None]: """Synchronous test client.""" from nsct.api.main import create_app app = create_app() with TestClient(app) as c: yield c # --------------------------------------------------------------------------- # /health # --------------------------------------------------------------------------- def test_health_returns_ok(client: TestClient) -> None: """GET /health should return status ok and the version.""" resp = client.get("/health") assert resp.status_code == 200 body = resp.json() assert body["status"] == "ok" assert "version" in body assert body["version"] == "0.1.0" # --------------------------------------------------------------------------- # /ready # --------------------------------------------------------------------------- def test_ready_returns_response(client: TestClient) -> None: """GET /ready should return a dict with status, llm key, etc.""" resp = client.get("/ready") assert resp.status_code == 200 body = resp.json() assert "status" in body assert "llm" in body def test_ready_status_field(client: TestClient) -> None: """GET /ready status should be 'ready' or 'not_ready'.""" resp = client.get("/ready") body = resp.json() assert body["status"] in ("ready", "not_ready") # --------------------------------------------------------------------------- # /providers # --------------------------------------------------------------------------- def test_providers_returns_provider_info(client: TestClient) -> None: """GET /providers should return keys for llm, vision, audio.""" resp = client.get("/providers") assert resp.status_code == 200 body = resp.json() assert "llm" in body assert "vision" in body assert "audio" in body def test_providers_no_secrets(client: TestClient) -> None: """GET /providers must not contain secrets.""" resp = client.get("/providers") body = resp.json() flat = str(body) assert "API_KEY" not in flat assert "secret" not in flat.lower().replace("available", "")