73 lines
2.7 KiB
Python
73 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
from mcp import ClientSession
|
|
|
|
pytestmark = pytest.mark.smoke
|
|
|
|
|
|
class TestMcpCatalogSurface:
|
|
"""Covers smoke-level MCP catalog discovery and tool execution paths."""
|
|
|
|
class TestTools:
|
|
"""Covers MCP tool-list and tool-call smoke behavior."""
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_lists_core_catalog_tools(self, mcp_session: ClientSession) -> None:
|
|
"""Ensures tools/list exposes the core catalog tool names."""
|
|
result = await mcp_session.list_tools()
|
|
tool_names = {tool.name for tool in result.tools}
|
|
|
|
assert {
|
|
"search_patterns",
|
|
"get_pattern_by_id",
|
|
"get_skill_document_by_id",
|
|
"search_prompts",
|
|
"get_prompt_by_id",
|
|
}.issubset(tool_names)
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_calls_search_patterns_tool(self, mcp_session: ClientSession) -> None:
|
|
"""Ensures tools/call succeeds for search_patterns with basic args."""
|
|
result = await mcp_session.call_tool(
|
|
"search_patterns",
|
|
{
|
|
"query": "pytest",
|
|
"limit": 5,
|
|
},
|
|
)
|
|
|
|
assert result.isError is False
|
|
assert result.content
|
|
|
|
class TestResources:
|
|
"""Covers MCP resource and resource-template discovery."""
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_lists_catalog_resources(self, mcp_session: ClientSession) -> None:
|
|
"""Ensures resources/list exposes core catalog resource URIs."""
|
|
result = await mcp_session.list_resources()
|
|
resource_uris = {str(resource.uri) for resource in result.resources}
|
|
|
|
assert "resource://catalog/skills_index" in resource_uris
|
|
assert "resource://catalog/prompts_index" in resource_uris
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_lists_resource_templates(self, mcp_session: ClientSession) -> None:
|
|
"""Ensures resources/templates/list includes skills and prompt templates."""
|
|
result = await mcp_session.list_resource_templates()
|
|
template_uris = {template.uriTemplate for template in result.resourceTemplates}
|
|
|
|
assert "resource://skills/{skill_id}/document" in template_uris
|
|
assert "resource://prompts/{prompt_id}/document" in template_uris
|
|
|
|
class TestPrompts:
|
|
"""Covers MCP prompt discovery surface."""
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_lists_registered_prompts(self, mcp_session: ClientSession) -> None:
|
|
"""Ensures prompts/list returns at least one registered prompt."""
|
|
result = await mcp_session.list_prompts()
|
|
|
|
assert result.prompts
|