You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB
Python

# backend/tests/test_ready.py — readiness 의존성 점검 + LLM 폴백 비차단
def test_health_liveness(client):
assert client.get("/api/health").json()["status"] == "ok"
def test_ready_ok_with_db(client):
r = client.get("/api/ready")
assert r.status_code == 200
body = r.json()
assert body["ready"] is True
assert body["checks"]["db"] == "ok"
assert body["checks"]["migrations"] == "ok"
assert body["checks"]["worker"] in ("manual", "scheduled")
def test_ready_llm_fallback_does_not_block(client, monkeypatch):
# Ollama 미가용이어도 ready 유지(heuristic 폴백)
monkeypatch.setattr(
"app.routers.ops.check_ollama",
lambda: {"reachable": False, "model": "x", "host": "y"},
)
r = client.get("/api/ready").json()
assert r["ready"] is True
assert r["checks"]["llm"].startswith("fallback")
def test_metrics_endpoint_text(client):
client.get("/api/dashboard") # 요청 1건 → 메트릭 누적
r = client.get("/api/metrics")
assert r.status_code == 200
assert "ari_http_requests_total" in r.text