feat: add production health smoke

This commit is contained in:
732642856
2026-07-18 01:22:35 +08:00
parent 42e4e29ac1
commit 8f0cafbb67
3 changed files with 173 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
from scripts.production_smoke import check
def test_health_route_declares_required_checks() -> None:
source = open("frontend/src/app/api/health/route.ts", encoding="utf-8").read()
for expected in (
"supabasePublicConfig",
"supabaseServiceRole",
"modelProvider",
"jyotishApi",
"JYOTISH_API_BASE",
):
assert expected in source
def test_production_smoke_accepts_health_degraded_status(monkeypatch) -> None:
def fake_fetch(url: str, timeout: float) -> tuple[int, str, float]:
if url.endswith("/api/health"):
return 503, '{"status":"blocked","checks":{"web":{},"jyotishApi":{}}}', 0.01
return 200, "Jyotisha", 0.01
monkeypatch.setattr("scripts.production_smoke.fetch", fake_fetch)
report = check("https://example.invalid", 1.0)
assert report["ok"] is True
assert report["checks"][1]["health_status"] == "blocked"