"""Tests for Enterprise MCP Server."""
import pytest
import asyncio
from unittest.mock import AsyncMock, MagicMock
from enterprise_mcp.services import SelfHealth, ServiceNowMCP
from enterprise_mcp.server import MCPServer, default_health_check
from enterprise_mcp.settings import ServerSettings
@pytest.mark.asyncio
async def test_default_health_check():
"""Test default health check function."""
result = await default_health_check()
assert result is True
@pytest.mark.asyncio
async def test_self_health_service():
"""Test SelfHealth service registration."""
health_service = SelfHealth()
mock_mcp = MagicMock()
# Mock the tool decorator
mock_mcp.tool = MagicMock(return_value=lambda func: func)
await health_service.register(mock_mcp)
# Verify tool decorator was called
assert mock_mcp.tool.called
@pytest.mark.asyncio
async def test_servicenow_service():
"""Test ServiceNow service registration."""
servicenow_service = ServiceNowMCP()
mock_mcp = MagicMock()
# Mock the tool decorator
mock_mcp.tool = MagicMock(return_value=lambda func: func)
await servicenow_service.register(mock_mcp)
# Verify tool decorator was called
assert mock_mcp.tool.called
def test_server_settings():
"""Test server settings initialization."""
settings = ServerSettings()
assert settings.HOST == "0.0.0.0"
# Port might be overridden by environment variables
assert isinstance(settings.PORT, int)
assert isinstance(settings.DEBUG, bool)
assert settings.MCP_BASE.startswith("http")
@pytest.mark.asyncio
async def test_mcp_server_creation():
"""Test MCP server creation."""
settings = ServerSettings()
server = MCPServer(settings)
assert server.settings == settings
assert server.readiness_check is not None
assert server.liveness_check is not None