File size: 1,150 Bytes
6d20eab | 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 36 37 38 39 | """Tests for incident endpoints – backward‑compatible Bayesian reroute."""
import pytest
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_report_incident():
payload = {
"component": "api-gateway",
"latency_p99": 450.0,
"error_rate": 0.0,
"service_mesh": "default",
"throughput": 100,
"source": "test",
}
resp = client.post("/api/v1/report_incident", json=payload)
assert resp.status_code == 200
assert resp.json()["status"] == "recorded"
@pytest.mark.xfail(reason="model mismatch – awaiting core framework sync")
def test_evaluate_incident_deprecated():
payload = {
"component": "checkout",
"latency_p99": 450.0,
"error_rate": 0.12,
"service_mesh": "default",
"throughput": 100,
"source": "test",
}
resp = client.post("/api/v1/v1/incidents/evaluate", json=payload)
assert resp.status_code == 200
body = resp.json()
assert "deprecation_notice" in body
assert "healing_intent" in body
assert body["healing_intent"]["risk_score"] is not None
|