import pytest

from a2a_agent import topics


def test_topic_helpers_return_exact_strings() -> None:
    room = "team"
    device = "device-b"

    assert topics.config_devices_topic(room) == "a2a/team/config/devices"
    assert topics.config_commander_topic(room) == "a2a/team/config/commander"
    assert topics.agent_card_topic(room, device) == "a2a/team/agents/device-b/card"
    assert topics.agent_status_topic(room, device) == "a2a/team/agents/device-b/status"
    assert topics.agent_status_filter(room) == "a2a/team/agents/+/status"
    assert topics.cmd_request_topic(room, device) == "a2a/team/cmd/device-b/request"
    assert topics.cmd_response_topic(room, device) == "a2a/team/cmd/device-b/response"
    assert topics.cmd_task_status_topic(room, device) == "a2a/team/cmd/device-b/task-status"
    assert topics.pairing_request_topic() == "a2a/_pairing/request"
    assert topics.pairing_reply_topic("ABC234") == "a2a/_pairing/reply/ABC234"


def test_topic_helpers_reject_slash_segments() -> None:
    with pytest.raises(ValueError):
        topics.cmd_request_topic("team/dev", "device-b")

    with pytest.raises(ValueError):
        topics.cmd_request_topic("team", "device/b")
