- 76 new tests covering CLI commands, API routes, auth, runner, load modules — coverage 99% (169 remaining lines are infrastructure) - Enhanced /health endpoint with DuckDB, bib, pipeline service checks - Added `stack health` CLI command with graceful degradation - SnapshotManager for DuckDB data versioning and rollback - .woodpecker.yml CI pipeline: lint, test (99% gate), marimo check - Error handling audit: no bare except clauses, all exceptions logged Closes #31, #32, #33, #34, #35.
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Tests for enhanced health check endpoint."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
class TestHealthChecks:
|
|
def test_health_returns_services(self) -> None:
|
|
from api.server import app
|
|
|
|
client = TestClient(app)
|
|
r = client.get("/health")
|
|
assert r.status_code == 200
|
|
data = r.json()
|
|
assert "services" in data
|
|
assert len(data["services"]) >= 3
|
|
assert data["version"] == "0.1.0"
|
|
assert data["status"] in ("ok", "degraded")
|
|
|
|
def test_service_names(self) -> None:
|
|
from api.server import app
|
|
|
|
client = TestClient(app)
|
|
r = client.get("/health")
|
|
names = {s["name"] for s in r.json()["services"]}
|
|
assert "duckdb" in names
|
|
assert "bib" in names
|
|
assert "pipelines" in names
|
|
|
|
def test_check_functions(self) -> None:
|
|
from api.routes.health import _check_bib, _check_duckdb, _check_pipelines
|
|
|
|
duck = _check_duckdb()
|
|
assert duck.name == "duckdb"
|
|
assert duck.status in ("ok", "degraded", "down")
|
|
|
|
bib = _check_bib()
|
|
assert bib.name == "bib"
|
|
assert bib.status in ("ok", "degraded", "down")
|
|
|
|
pipes = _check_pipelines()
|
|
assert pipes.name == "pipelines"
|
|
assert pipes.status == "ok"
|
|
assert "registered" in pipes.detail
|