Invoca el agente real incident_analyzer (assets del repo, LLM mock) vía TestClient y comprueba status=completed, final_output y que el decision_path recorre los seis nodos del grafo. Añade conftest con la fixture integration_client (env apuntando a agents/ y policies/ del repo, caches DI limpiadas). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
"""Integration: invoca incident_analyzer real con escenario MOS (sin HITL)."""
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
EXAMPLES = (
|
|
Path(__file__).parent.parent.parent / "agents" / "incident_analyzer" / "examples"
|
|
)
|
|
|
|
|
|
@pytest.mark.integration
|
|
def test_happy_path_completa_sin_hitl(integration_client) -> None: # type: ignore[no-untyped-def]
|
|
payload = (EXAMPLES / "02_mos_degradation_pool_sbc.txt").read_text(encoding="utf-8")
|
|
r = integration_client.post("/agents/incident_analyzer/invoke", json={"input": payload})
|
|
assert r.status_code == 200
|
|
body = r.json()
|
|
assert body["status"] == "completed"
|
|
assert body["agent_name"] == "incident_analyzer"
|
|
assert body["agent_version"] in {"v1", "v2"}
|
|
assert body["final_output"]["severity"] in {"low", "medium", "high", "critical"}
|
|
# Decision_path debe contener todos los nodos.
|
|
steps = {s["step"] for s in body["decision_path"]}
|
|
assert "validate_input" in steps
|
|
assert "llm_reason" in steps
|
|
assert "validate_output" in steps
|
|
assert "propose_actions" in steps
|
|
assert "approve_gate" in steps
|
|
assert "finalize" in steps
|