50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
from src.api.v1.agents import router
|
|
|
|
|
|
def test_service_health_gap_matrix_endpoint_returns_committed_snapshot():
|
|
app = FastAPI()
|
|
app.include_router(router, prefix="/api/v1")
|
|
client = TestClient(app)
|
|
|
|
response = client.get("/api/v1/agents/service-health-gap-matrix")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["schema_version"] == "service_health_gap_matrix_v1"
|
|
assert data["program_status"]["current_task_id"] == "P1-005"
|
|
assert data["program_status"]["next_task_id"] == "P1-006"
|
|
assert data["program_status"]["read_only_mode"] is True
|
|
assert data["rollups"]["total_targets"] == len(data["service_health_targets"]) == 10
|
|
assert data["rollups"]["service_restart_allowed_count"] == 0
|
|
assert data["rollups"]["endpoint_change_allowed_count"] == 0
|
|
assert data["rollups"]["active_probe_allowed_count"] == 0
|
|
assert data["rollups"]["notification_send_allowed_count"] == 0
|
|
assert data["rollups"]["runtime_execution_allowed_count"] == 0
|
|
assert data["operation_boundaries"]["service_restart_allowed"] is False
|
|
assert data["operation_boundaries"]["endpoint_change_allowed"] is False
|
|
assert data["operation_boundaries"]["active_probe_allowed"] is False
|
|
assert data["operation_boundaries"]["notification_send_allowed"] is False
|
|
assert data["operation_boundaries"]["runtime_execution_allowed"] is False
|
|
assert data["approval_boundaries"]["active_probe_approved"] is False
|
|
assert data["approval_boundaries"]["endpoint_change_approved"] is False
|
|
assert data["approval_boundaries"]["notification_send_approved"] is False
|
|
assert any(
|
|
target["target_id"] == "ollama_three_layer_health_contract"
|
|
and target["status"] == "action_required"
|
|
for target in data["service_health_targets"]
|
|
)
|
|
assert any(
|
|
gap["gap_id"] == "endpoint_reference_stale_hosts"
|
|
for gap in data["health_gaps"]
|
|
)
|
|
assert any(
|
|
endpoint["endpoint_id"] == "legacy_188_ollama_provider_endpoint"
|
|
for endpoint in data["stale_endpoints"]
|
|
)
|
|
assert "active probe 批准" in data["operator_contract"]["must_not_interpret_as"]
|