66 lines
1.6 KiB
Python
66 lines
1.6 KiB
Python
"""Tests de modelos de ejecución."""
|
|
|
|
from datetime import UTC, datetime
|
|
from uuid import uuid4
|
|
|
|
from agentforge_core.domain.execution import (
|
|
AgentExecution,
|
|
AgentExecutionSummary,
|
|
DecisionStep,
|
|
ProposedAction,
|
|
)
|
|
|
|
|
|
def test_proposed_action_risk_score_in_rango() -> None:
|
|
a = ProposedAction(
|
|
id="act-1",
|
|
action="rollback_image",
|
|
target="cscf-01",
|
|
risk_score=4,
|
|
rollback_plan="redeploy 4.7.1",
|
|
requires_approval=True,
|
|
)
|
|
assert a.risk_score == 4
|
|
|
|
|
|
def test_decision_step_serializable() -> None:
|
|
s = DecisionStep(
|
|
step="llm_reason",
|
|
timestamp=datetime.now(UTC),
|
|
duration_ms=120,
|
|
detail={"tokens_in": 100},
|
|
)
|
|
assert s.model_dump()["detail"]["tokens_in"] == 100
|
|
|
|
|
|
def test_agent_execution_status_running() -> None:
|
|
e = AgentExecution(
|
|
trace_id=uuid4(),
|
|
agent_name="incident_analyzer",
|
|
agent_version="v1",
|
|
status="running",
|
|
started_at=datetime.now(UTC),
|
|
finished_at=None,
|
|
decision_path=[],
|
|
violations=[],
|
|
proposed_actions=[],
|
|
needs_human_for=None,
|
|
final_output=None,
|
|
error=None,
|
|
)
|
|
assert e.status == "running"
|
|
|
|
|
|
def test_agent_execution_summary_no_incluye_decision_path() -> None:
|
|
s = AgentExecutionSummary(
|
|
trace_id=uuid4(),
|
|
agent_name="x",
|
|
agent_version="v1",
|
|
status="completed",
|
|
started_at=datetime.now(UTC),
|
|
finished_at=datetime.now(UTC),
|
|
n_violations=0,
|
|
n_proposed_actions=2,
|
|
)
|
|
assert "decision_path" not in s.model_dump()
|