mcp tests
This commit is contained in:
@@ -6,25 +6,56 @@ from mcp import ClientSession
|
|||||||
pytestmark = pytest.mark.smoke
|
pytestmark = pytest.mark.smoke
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED_TOOL_NAMES = (
|
||||||
|
"search_patterns",
|
||||||
|
"get_pattern_by_id",
|
||||||
|
"get_skill_document_by_id",
|
||||||
|
"search_prompts",
|
||||||
|
"get_prompt_by_id",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED_RESOURCE_URIS = (
|
||||||
|
"resource://catalog/skills_index",
|
||||||
|
"resource://catalog/prompts_index",
|
||||||
|
)
|
||||||
|
|
||||||
|
TOOL_NAME_PARAMETERS = tuple(
|
||||||
|
pytest.param(
|
||||||
|
tool_name,
|
||||||
|
id=tool_name.replace("_", "-"),
|
||||||
|
)
|
||||||
|
for tool_name in REQUIRED_TOOL_NAMES
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
RESOURCE_URI_PARAMETERS = tuple(
|
||||||
|
pytest.param(
|
||||||
|
resource_uri,
|
||||||
|
id=resource_uri.removeprefix("resource://").replace("/", "-"),
|
||||||
|
)
|
||||||
|
for resource_uri in REQUIRED_RESOURCE_URIS
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestMcpCatalogSurface:
|
class TestMcpCatalogSurface:
|
||||||
"""Covers smoke-level MCP catalog discovery and tool execution paths."""
|
"""Covers smoke-level MCP catalog discovery and tool execution paths."""
|
||||||
|
|
||||||
class TestTools:
|
class TestTools:
|
||||||
"""Covers MCP tool-list and tool-call smoke behavior."""
|
"""Covers MCP tool-list and tool-call smoke behavior."""
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("tool_name", TOOL_NAME_PARAMETERS)
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_lists_core_catalog_tools(self, mcp_session: ClientSession) -> None:
|
async def test_lists_core_catalog_tools(
|
||||||
"""Ensures tools/list exposes the core catalog tool names."""
|
self,
|
||||||
|
mcp_session: ClientSession,
|
||||||
|
tool_name: str,
|
||||||
|
) -> None:
|
||||||
|
"""Ensures tools/list exposes each required core catalog tool name."""
|
||||||
result = await mcp_session.list_tools()
|
result = await mcp_session.list_tools()
|
||||||
tool_names = {tool.name for tool in result.tools}
|
tool_names = {tool.name for tool in result.tools}
|
||||||
|
|
||||||
assert {
|
assert tool_name in tool_names
|
||||||
"search_patterns",
|
|
||||||
"get_pattern_by_id",
|
|
||||||
"get_skill_document_by_id",
|
|
||||||
"search_prompts",
|
|
||||||
"get_prompt_by_id",
|
|
||||||
}.issubset(tool_names)
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_calls_search_patterns_tool(self, mcp_session: ClientSession) -> None:
|
async def test_calls_search_patterns_tool(self, mcp_session: ClientSession) -> None:
|
||||||
@@ -43,14 +74,18 @@ class TestMcpCatalogSurface:
|
|||||||
class TestResources:
|
class TestResources:
|
||||||
"""Covers MCP resource and resource-template discovery."""
|
"""Covers MCP resource and resource-template discovery."""
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("resource_uri", RESOURCE_URI_PARAMETERS)
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_lists_catalog_resources(self, mcp_session: ClientSession) -> None:
|
async def test_lists_catalog_resources(
|
||||||
"""Ensures resources/list exposes core catalog resource URIs."""
|
self,
|
||||||
|
mcp_session: ClientSession,
|
||||||
|
resource_uri: str,
|
||||||
|
) -> None:
|
||||||
|
"""Ensures resources/list exposes each required catalog resource URI."""
|
||||||
result = await mcp_session.list_resources()
|
result = await mcp_session.list_resources()
|
||||||
resource_uris = {str(resource.uri) for resource in result.resources}
|
resource_uris = {str(resource.uri) for resource in result.resources}
|
||||||
|
|
||||||
assert "resource://catalog/skills_index" in resource_uris
|
assert resource_uri in resource_uris
|
||||||
assert "resource://catalog/prompts_index" in resource_uris
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_lists_resource_templates(self, mcp_session: ClientSession) -> None:
|
async def test_lists_resource_templates(self, mcp_session: ClientSession) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user