"""
Copyright (C) 2025 Luciano Guerche

This file is part of rabbitmq-mcp-server.

rabbitmq-mcp-server is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

rabbitmq-mcp-server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with rabbitmq-mcp-server. If not, see <https://www.gnu.org/licenses/>.
"""

"""Unit tests for MCP protocol methods."""

import pytest

from config.settings import Settings
from mcp_server.server import PROTOCOL_VERSION, SERVER_NAME, SERVER_VERSION, MCPServer


class TestMCPProtocol:
    """Test MCP protocol implementation."""

    def test_protocol_constants(self) -> None:
        """Test MCP protocol constants are correct."""
        assert PROTOCOL_VERSION == "2024-11-05"
        assert SERVER_NAME == "rabbitmq-mcp-server"
        assert SERVER_VERSION == "3.0.0"

    @pytest.mark.asyncio
    async def test_server_initialization(self) -> None:
        """Test server can be initialized."""
        settings = Settings(
            operations_registry_path="data/operations.json",
            embeddings_path="data/embeddings.json",
        )
        server = MCPServer(settings)

        assert server is not None
        assert server.server.name == SERVER_NAME

    @pytest.mark.asyncio
    async def test_tool_registration(self) -> None:
        """Test tools are registered with the server."""
        settings = Settings(
            operations_registry_path="data/operations.json",
            embeddings_path="data/embeddings.json",
        )
        server = MCPServer(settings)

        # Verify server has registered handlers
        assert hasattr(server.server, "list_tools")
        assert hasattr(server.server, "call_tool")
