Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/aignostics/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,18 @@ def mock_uvicorn_run(app, host=None, port=None):


@pytest.mark.unit
def test_cli_mcp_run_command(runner: CliRunner) -> None:
def test_cli_mcp_run_command(runner: CliRunner, record_property) -> None:
"""Test run command starts the MCP server."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
with patch(PATCH_RUN) as mock_run:
runner.invoke(cli, ["mcp", "run"])
mock_run.assert_called_once()


@pytest.mark.unit
def test_cli_mcp_list_tools(runner: CliRunner) -> None:
def test_cli_mcp_list_tools(runner: CliRunner, record_property) -> None:
"""Test list-tools command displays discovered tools."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
test_server = FastMCP("test")

@test_server.tool
Expand All @@ -322,8 +324,9 @@ def test_tool() -> str:


@pytest.mark.unit
def test_cli_mcp_list_tools_empty(runner: CliRunner) -> None:
def test_cli_mcp_list_tools_empty(runner: CliRunner, record_property) -> None:
"""Test list-tools command with no tools."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
with patch(PATCH_MCP_LOCATE_IMPLEMENTATIONS, return_value=[]):
result = runner.invoke(cli, ["mcp", "list-tools"])
assert result.exit_code == 0
Expand Down
24 changes: 16 additions & 8 deletions tests/aignostics/utils/mcp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@


@pytest.mark.unit
def test_mcp_discover_servers_returns_list() -> None:
def test_mcp_discover_servers_returns_list(record_property) -> None:
"""Test that mcp_discover_servers returns a list of servers."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
test_server = FastMCP("test_server")
with patch(PATCH_LOCATE_IMPLEMENTATIONS, return_value=[test_server]) as mock_locate:
servers = mcp_discover_servers()
Expand All @@ -36,16 +37,18 @@ def test_mcp_discover_servers_returns_list() -> None:


@pytest.mark.unit
def test_mcp_discover_servers_empty() -> None:
def test_mcp_discover_servers_empty(record_property) -> None:
"""Test that mcp_discover_servers handles no servers found."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
with patch(PATCH_LOCATE_IMPLEMENTATIONS, return_value=[]):
servers = mcp_discover_servers()
assert servers == []


@pytest.mark.integration
def test_mcp_discover_servers_real_discovery() -> None:
def test_mcp_discover_servers_real_discovery(record_property) -> None:
"""Test discovery without mocking."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
servers = mcp_discover_servers()
assert isinstance(servers, list)
for server in servers:
Expand All @@ -58,17 +61,19 @@ def test_mcp_discover_servers_real_discovery() -> None:


@pytest.mark.unit
def test_mcp_create_server() -> None:
def test_mcp_create_server(record_property) -> None:
"""Test server creation."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
with patch(PATCH_LOCATE_IMPLEMENTATIONS, return_value=[]):
server = mcp_create_server()
assert isinstance(server, FastMCP)
assert server.name == MCP_SERVER_NAME


@pytest.mark.unit
def test_mcp_create_server_mounts_discovered() -> None:
def test_mcp_create_server_mounts_discovered(record_property) -> None:
"""Test that mcp_create_server mounts discovered servers with their tools."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
plugin1 = FastMCP("plugin1")
plugin2 = FastMCP("plugin2")

Expand Down Expand Up @@ -100,8 +105,9 @@ def plugin2_tool() -> str:


@pytest.mark.unit
def test_mcp_create_server_skips_duplicate_names(caplog: pytest.LogCaptureFixture) -> None:
def test_mcp_create_server_skips_duplicate_names(caplog: pytest.LogCaptureFixture, record_property) -> None:
"""Test that servers with duplicate names are skipped with warning."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
dup1 = FastMCP("duplicate_name")
dup2 = FastMCP("duplicate_name")
unique = FastMCP("unique_name")
Expand Down Expand Up @@ -144,8 +150,9 @@ def unique_tool() -> str:


@pytest.mark.unit
def test_mcp_list_tools_returns_tool_info() -> None:
def test_mcp_list_tools_returns_tool_info(record_property) -> None:
"""Test that mcp_list_tools returns correct tool information."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
test_server = FastMCP("test")

@test_server.tool
Expand All @@ -161,8 +168,9 @@ def test_tool(param: str) -> str:


@pytest.mark.unit
def test_mcp_list_tools_empty() -> None:
def test_mcp_list_tools_empty(record_property) -> None:
"""Test mcp_list_tools with no discovered tools."""
record_property("tested-item-id", "SPEC-UTILS-SERVICE")
with patch(PATCH_LOCATE_IMPLEMENTATIONS, return_value=[]):
tools = mcp_list_tools()
# Should return empty list when no plugins have tools
Expand Down
Loading