feat(domain): añade modelos GuardrailViolation, PolicyDefinition y AgentExecution
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Tests del modelo GuardrailViolation."""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from agentforge_core.domain.guardrail import GuardrailViolation
|
||||
|
||||
|
||||
def test_guardrail_violation_minimo_valido() -> None:
|
||||
v = GuardrailViolation(
|
||||
trace_id=uuid4(),
|
||||
timestamp=datetime.now(UTC),
|
||||
stage="input",
|
||||
validator="DetectPII",
|
||||
severity="block",
|
||||
message="DNI detectado",
|
||||
blocked=True,
|
||||
)
|
||||
assert v.blocked is True
|
||||
|
||||
|
||||
def test_guardrail_violation_rechaza_severity_invalido() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
GuardrailViolation(
|
||||
trace_id=uuid4(),
|
||||
timestamp=datetime.now(UTC),
|
||||
stage="input",
|
||||
validator="x",
|
||||
severity="critical", # type: ignore[arg-type]
|
||||
message="x",
|
||||
blocked=True,
|
||||
)
|
||||
Reference in New Issue
Block a user