from __future__ import annotations

from app.livekit.policies.agent_finalization import (
    final_stop_from_agent_result,
    stop_status_for_agent_result_type,
)


def test_stop_status_for_agent_result_type_uses_conta_contract() -> None:
    assert stop_status_for_agent_result_type("resolvido") == "stop_resolvido_e_finalizado"
    assert stop_status_for_agent_result_type("nao_resolvido") == "stop_nao_resolvido"
    assert stop_status_for_agent_result_type("resolvido_outros_assuntos") == "stop_outro_assunto"
    assert stop_status_for_agent_result_type("outros_assuntos") == "stop_outro_assunto"
    assert stop_status_for_agent_result_type("erro_falha_sistema") == "stop_falha_sistema"
    assert stop_status_for_agent_result_type("erro_no_match") == "stop_no_match"


def test_final_stop_from_agent_result_ignores_non_terminal_result_types() -> None:
    assert final_stop_from_agent_result({"type": "final", "content": "texto"}) is None
    assert final_stop_from_agent_result({"content": "texto"}) is None
    assert final_stop_from_agent_result(None) is None
