"""Tests for Agent Status SDK models."""

import pytest
from agent_status.models import Agent, AgentStatus, RunResult, Verdict


class TestVerdict:
    def test_verdict_values(self):
        assert Verdict.UP.value == "UP"
        assert Verdict.DEGRADED.value == "DEGRADED"
        assert Verdict.DOWN.value == "DOWN"
        assert Verdict.UNKNOWN.value == "UNKNOWN"

    def test_verdict_from_string(self):
        assert Verdict("UP") == Verdict.UP
        assert Verdict("DOWN") == Verdict.DOWN


class TestAgent:
    def test_agent_minimal(self):
        agent = Agent(
            id="123",
            name="Test Agent",
            endpoint_url="https://api.example.com/chat",
        )
        assert agent.id == "123"
        assert agent.name == "Test Agent"
        assert agent.status == "active"
        assert agent.interval_minutes == 360

    def test_agent_full(self):
        agent = Agent(
            id="123",
            name="Test Agent",
            endpoint_url="https://api.example.com/chat",
            interval_minutes=60,
            max_nodes_per_run=10,
            geos=["us", "eu"],
            eval_type="llm_judge",
            streaming=True,
        )
        assert agent.interval_minutes == 60
        assert agent.geos == ["us", "eu"]
        assert agent.streaming is True


class TestAgentStatus:
    def test_status_minimal(self):
        status = AgentStatus(
            agent_id="123",
            verdict=Verdict.UP,
        )
        assert status.verdict == Verdict.UP
        assert status.total_checks == 0

    def test_status_with_metrics(self):
        status = AgentStatus(
            agent_id="123",
            verdict=Verdict.DEGRADED,
            uptime_24h=95.5,
            latency_p95=1500,
            pass_rate=0.95,
        )
        assert status.uptime_24h == 95.5
        assert status.latency_p95 == 1500


class TestRunResult:
    def test_run_result_minimal(self):
        result = RunResult(
            decision_id="abc",
            verdict=Verdict.UP,
        )
        assert result.decision_id == "abc"
        assert result.total_probes == 0

    def test_run_result_full(self):
        result = RunResult(
            decision_id="abc",
            verdict=Verdict.UP,
            latency_p50=100,
            latency_p95=250,
            pass_rate=1.0,
            total_probes=10,
            successful_probes=10,
            failed_probes=0,
        )
        assert result.latency_p95 == 250
        assert result.successful_probes == 10
