File size: 1,216 Bytes
46c1e33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
06b738c
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Tests for health check and root endpoints."""

from __future__ import annotations

from fastapi.testclient import TestClient


def test_root_returns_api_info(client: TestClient) -> None:
    """Root endpoint should return API name, version, and status."""
    response = client.get("/")
    assert response.status_code == 200
    data = response.json()
    assert data["name"] == "CrownCode Backend API"
    assert data["status"] == "running"
    assert "version" in data


def test_health_endpoint(client: TestClient) -> None:
    """Health endpoint should return ok status with services info."""
    response = client.get("/api/health")
    assert response.status_code == 200
    data = response.json()
    assert data["status"] == "ok"
    assert "services" in data


def test_health_reports_model_inventory(client: TestClient) -> None:
    """Health says what actually loaded, not just that the process is up."""
    data = client.get("/api/health").json()
    models = data["models"]
    assert "xai" in models and "available" in models["xai"]
    assert models["xai"]["ensembleTotal"] == 11
    assert "wav2vec2" in models and "clap" in models and "meta" in models
    assert models["jobs"]["running"] >= 0