"""Tests that the correct tools are registered and dangerous ones are excluded."""

import pytest

from influ2_mcp.server import mcp


@pytest.fixture
async def tools():
    return await mcp.list_tools()


@pytest.fixture
async def tool_names(tools):
    return {t.name for t in tools}


class TestToolRegistry:
    """Verify exactly the right tools are exposed — no more, no less."""

    EXPECTED_TOOLS = {
        "influ2_list_clients",
        "influ2_create_client",
        "influ2_list_cohorts",
        "influ2_get_cohort_details",
        "influ2_list_targets",
        "influ2_manage_targets",
        "influ2_list_contents",
        "influ2_list_asset_templates",
        "influ2_upload_asset",
        "influ2_check_job",
    }

    @pytest.mark.asyncio
    async def test_tool_count(self, tools):
        assert len(tools) == 10, f"Expected 10 tools, got {len(tools)}"

    @pytest.mark.asyncio
    async def test_expected_tools_present(self, tool_names):
        missing = self.EXPECTED_TOOLS - tool_names
        assert not missing, f"Missing tools: {missing}"

    @pytest.mark.asyncio
    async def test_no_extra_tools(self, tool_names):
        extra = tool_names - self.EXPECTED_TOOLS
        assert not extra, f"Unexpected extra tools: {extra}"

    @pytest.mark.asyncio
    async def test_create_cohort_removed(self, tool_names):
        """Unstable API — must not be exposed to users."""
        assert "influ2_create_cohort" not in tool_names

    @pytest.mark.asyncio
    async def test_add_content_removed(self, tool_names):
        """Unstable API — must not be exposed to users."""
        assert "influ2_add_content" not in tool_names

    @pytest.mark.asyncio
    async def test_no_delete_cohort_tool(self, tool_names):
        """No cohort deletion should ever exist."""
        assert "influ2_delete_cohort" not in tool_names

    @pytest.mark.asyncio
    async def test_no_delete_client_tool(self, tool_names):
        """No client deletion should ever exist."""
        assert "influ2_delete_client" not in tool_names
