changed to skill provider
This commit is contained in:
+30
-130
@@ -6,173 +6,73 @@ import pytest
|
||||
|
||||
pytestmark = pytest.mark.smoke
|
||||
|
||||
|
||||
REQUIRED_TOOL_NAMES = (
|
||||
RETIRED_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
|
||||
)
|
||||
|
||||
|
||||
SEARCH_QUERY_PARAMETERS = (
|
||||
pytest.param(
|
||||
"pytest",
|
||||
{"pytesting"},
|
||||
id="query-pytest",
|
||||
),
|
||||
pytest.param(
|
||||
"asyncio",
|
||||
{"pytesting", "async-fastapi-sqlmodel"},
|
||||
id="query-asyncio",
|
||||
),
|
||||
pytest.param(
|
||||
"fastapi testing",
|
||||
{"pytesting"},
|
||||
id="query-fastapi-testing",
|
||||
),
|
||||
pytest.param(
|
||||
"asyncio fastapi testing deterministic pytest",
|
||||
{"pytesting"},
|
||||
id="query-composite-async-fastapi-testing-deterministic-pytest",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
RESOURCE_URI_PARAMETERS = tuple(
|
||||
pytest.param(
|
||||
resource_uri,
|
||||
id=resource_uri.removeprefix("resource://").replace("/", "-"),
|
||||
)
|
||||
for resource_uri in REQUIRED_RESOURCE_URIS
|
||||
)
|
||||
|
||||
|
||||
class TestMcpCatalogSurface:
|
||||
"""Covers smoke-level MCP catalog discovery and tool execution paths."""
|
||||
class TestMcpSkillsSurface:
|
||||
"""Covers native skill resources over the HTTP MCP surface."""
|
||||
|
||||
class TestTools:
|
||||
"""Covers MCP tool-list and tool-call smoke behavior."""
|
||||
"""Covers generic resource fallback tools for native skills."""
|
||||
|
||||
@pytest.mark.parametrize("tool_name", TOOL_NAME_PARAMETERS)
|
||||
@pytest.mark.asyncio
|
||||
async def test_lists_core_catalog_tools(
|
||||
self,
|
||||
mcp_session_factory,
|
||||
tool_name: str,
|
||||
) -> None:
|
||||
"""Ensures tools/list exposes each required core catalog tool name."""
|
||||
async def test_lists_resource_fallback_tools(self, mcp_session_factory) -> None:
|
||||
"""Ensures generic resource tools replace skill-specific catalog tools."""
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
result = await mcp_session.list_tools()
|
||||
tool_names = {tool.name for tool in result.tools}
|
||||
|
||||
assert tool_name in tool_names
|
||||
assert {"list_resources", "read_resource"}.issubset(tool_names)
|
||||
assert RETIRED_TOOL_NAMES.isdisjoint(tool_names)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calls_search_patterns_tool(self, mcp_session_factory) -> None:
|
||||
"""Ensures tools/call succeeds for search_patterns with basic args."""
|
||||
async def test_reads_skill_through_fallback_tool(self, mcp_session_factory) -> None:
|
||||
"""Ensures tool-only clients can read a native skill resource."""
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
result = await mcp_session.call_tool(
|
||||
"search_patterns",
|
||||
{
|
||||
"query": "pytest",
|
||||
"limit": 5,
|
||||
},
|
||||
"read_resource",
|
||||
{"uri": "skill://mcp-details/SKILL.md"},
|
||||
)
|
||||
|
||||
assert result.isError is False
|
||||
assert result.content
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("query", "expected_skill_ids"),
|
||||
SEARCH_QUERY_PARAMETERS,
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_patterns_matches_expected_skills_for_query_terms(
|
||||
self,
|
||||
mcp_session_factory,
|
||||
query: str,
|
||||
expected_skill_ids: set[str],
|
||||
) -> None:
|
||||
"""Ensures query terms return expected skill IDs from search_patterns."""
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
result = await mcp_session.call_tool(
|
||||
"search_patterns",
|
||||
{
|
||||
"query": query,
|
||||
"limit": 20,
|
||||
},
|
||||
)
|
||||
|
||||
assert result.isError is False
|
||||
assert result.content
|
||||
|
||||
payload = json.loads(result.content[0].text)
|
||||
found_skill_ids = {pattern["id"] for pattern in payload["patterns"]}
|
||||
|
||||
assert expected_skill_ids.issubset(found_skill_ids)
|
||||
|
||||
class TestResources:
|
||||
"""Covers MCP resource and resource-template discovery."""
|
||||
"""Covers native skill resources, manifests, and file templates."""
|
||||
|
||||
@pytest.mark.parametrize("resource_uri", RESOURCE_URI_PARAMETERS)
|
||||
@pytest.mark.asyncio
|
||||
async def test_lists_catalog_resources(
|
||||
self,
|
||||
mcp_session_factory,
|
||||
resource_uri: str,
|
||||
) -> None:
|
||||
"""Ensures resources/list exposes each required catalog resource URI."""
|
||||
async def test_lists_main_file_and_manifest(self, mcp_session_factory) -> None:
|
||||
"""Ensures resources/list exposes native skill entry points."""
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
result = await mcp_session.list_resources()
|
||||
resource_uris = {str(resource.uri) for resource in result.resources}
|
||||
|
||||
assert resource_uri in resource_uris
|
||||
assert "skill://mcp-details/SKILL.md" in resource_uris
|
||||
assert "skill://mcp-details/_manifest" in resource_uris
|
||||
assert "resource://catalog/skills_index" not in resource_uris
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lists_resource_templates(self, mcp_session_factory) -> None:
|
||||
"""Ensures resources/templates/list includes skills and prompt templates."""
|
||||
"""Ensures supporting files use per-skill wildcard templates."""
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
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
|
||||
assert "skill://mcp-details/{path*}" in template_uris
|
||||
assert "resource://skills/{skill_id}/document" not in template_uris
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_reads_mcp_details_skill_document(self, mcp_session_factory) -> None:
|
||||
"""Ensures read_resource resolves the mcp-details skill document URI."""
|
||||
async def test_reads_manifest_and_supporting_file(self, mcp_session_factory) -> None:
|
||||
"""Ensures manifest paths resolve through the supporting-file template."""
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
result = await mcp_session.call_tool(
|
||||
"read_resource",
|
||||
{"uri": "resource://skills/mcp-details/document"},
|
||||
)
|
||||
manifest_result = await mcp_session.read_resource("skill://mcp-details/_manifest")
|
||||
manifest = json.loads(manifest_result.contents[0].text)
|
||||
reference = next(file["path"] for file in manifest["files"] if file["path"].startswith("references/"))
|
||||
reference_result = await mcp_session.read_resource(f"skill://mcp-details/{reference}")
|
||||
|
||||
assert result.isError is False
|
||||
assert result.content
|
||||
|
||||
class TestPrompts:
|
||||
"""Covers MCP prompt discovery surface."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lists_registered_prompts(self, mcp_session_factory) -> None:
|
||||
"""Ensures prompts/list returns at least one registered prompt."""
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
result = await mcp_session.list_prompts()
|
||||
|
||||
assert result.prompts
|
||||
assert manifest["skill"] == "mcp-details"
|
||||
assert reference_result.contents
|
||||
|
||||
Reference in New Issue
Block a user