"""Tests for {{ name }}.

These tests verify that the agent implements the
SpecialistAgent protocol correctly and that tools are configured.
"""

import pytest

from {{ agent_slug }} import CAPABILITIES, {{ agent_class }}
from {{ agent_slug }}.tools import get_tools, TOOLS


class Test{{ agent_class }}:
    """Tests for {{ agent_class }}."""

    def test_has_required_attributes(self) -> None:
        """Agent has required protocol attributes."""
        agent = {{ agent_class }}()
        assert hasattr(agent, "name")
        assert hasattr(agent, "capabilities")
        assert agent.name == "{{ agent_slug }}"

    def test_capabilities_not_empty(self) -> None:
        """Capabilities description is not empty."""
        assert CAPABILITIES
        assert len(CAPABILITIES) > 0

    def test_has_run_method(self) -> None:
        """Agent has async run method."""
        agent = {{ agent_class }}()
        assert hasattr(agent, "run")
        assert callable(agent.run)

    def test_has_as_tool_method(self) -> None:
        """Agent has as_tool method."""
        agent = {{ agent_class }}()
        assert hasattr(agent, "as_tool")
        assert callable(agent.as_tool)

    def test_agent_has_tools(self) -> None:
        """Agent exposes its tools."""
        agent = {{ agent_class }}()
        assert hasattr(agent, "tools")
        assert len(agent.tools) >= 2


class TestTools:
    """Tests for agent tools."""

    def test_get_tools_returns_tools(self) -> None:
        """get_tools function returns a list of tools."""
        tools = get_tools()
        assert isinstance(tools, list)
        assert len(tools) >= 2

    def test_tools_have_ainvoke(self) -> None:
        """All tools are async callable."""
        tools = get_tools()
        for tool in tools:
            assert hasattr(tool, "ainvoke"), f"Tool {tool.name} missing ainvoke"

    def test_tools_have_descriptions(self) -> None:
        """All tools have descriptions for the LLM."""
        tools = get_tools()
        for tool in tools:
            assert tool.description, f"Tool {tool.name} has no description"

    def test_expected_tools_present(self) -> None:
        """Expected generic SDK tools are present."""
        tools = get_tools()
        tool_names = [t.name for t in tools]
        assert "api_get" in tool_names, "api_get tool not found"
        assert "fetch_file" in tool_names, "fetch_file tool not found"
