Files
prompts/tests/web/test_endpoint_connections.py
T
2026-08-08 00:14:31 -05:00

67 lines
2.6 KiB
Python

from __future__ import annotations
import pytest
from httpx import AsyncClient
pytestmark = pytest.mark.smoke
class TestMcpHttpEndpoints:
"""Covers smoke-level HTTP checks for mounted MCP runtime endpoints."""
class TestHealthz:
"""Covers health endpoint smoke behavior."""
@pytest.mark.asyncio
async def test_returns_ok_payload(self, client: AsyncClient) -> None:
"""Ensures GET /healthz responds with a healthy status payload."""
response = await client.get("/healthz")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
class TestDocsRoute:
"""Covers static docs route smoke behavior."""
@pytest.mark.asyncio
async def test_serves_docs_entrypoint(self, client: AsyncClient) -> None:
"""Ensures GET /docs returns the docs site entrypoint response."""
response = await client.get("/docs", follow_redirects=True)
assert response.status_code == 200
assert "text/html" in response.headers["content-type"]
class TestMcpRoute:
"""Covers MCP transport endpoint smoke behavior."""
@pytest.mark.asyncio
async def test_tools_bridge_native_skill_resources(self, mcp_session_factory) -> None:
"""Ensures tool-only clients can discover and read native skill resources."""
async with mcp_session_factory() as mcp_session:
tools_result = await mcp_session.list_tools()
list_result = await mcp_session.call_tool("list_resources")
read_result = await mcp_session.call_tool(
"read_resource",
{"uri": "skill://mcp-details/SKILL.md"},
)
assert {tool.name for tool in tools_result.tools} == {
"list_resources",
"read_resource",
"search_skills",
}
assert "skill://mcp-details/SKILL.md" in list_result.content[0].text
assert "# MCP Details" in read_result.content[0].text
@pytest.mark.asyncio
async def test_accepts_initialize_jsonrpc_request(
self,
mcp_session_factory,
) -> None:
"""Ensures POST /mcp accepts an initialize JSON-RPC request."""
async with mcp_session_factory(initialize=False) as mcp_session_uninitialized:
initialize_result = await mcp_session_uninitialized.initialize()
assert initialize_result.protocol_version
assert initialize_result.server_info.name