better web tests
This commit is contained in:
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
from mcp import ClientSession
|
||||
|
||||
pytestmark = pytest.mark.smoke
|
||||
|
||||
@@ -39,7 +38,7 @@ class TestMcpHttpEndpoints:
|
||||
async def test_rejects_get_stream_without_support(
|
||||
self,
|
||||
client: AsyncClient,
|
||||
mcp_session: ClientSession,
|
||||
mcp_session_factory,
|
||||
) -> None:
|
||||
"""Ensures GET /mcp returns method not allowed for current transport mode."""
|
||||
response = await client.get(
|
||||
@@ -47,18 +46,20 @@ class TestMcpHttpEndpoints:
|
||||
headers={"Accept": "text/event-stream"},
|
||||
)
|
||||
|
||||
# Keep the SDK-backed session in use for this route smoke lane.
|
||||
await mcp_session.list_tools()
|
||||
async with mcp_session_factory() as mcp_session:
|
||||
# Keep the SDK-backed session in use for this route smoke lane.
|
||||
await mcp_session.list_tools()
|
||||
|
||||
assert response.status_code == 405
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_accepts_initialize_jsonrpc_request(
|
||||
self,
|
||||
mcp_session_uninitialized: ClientSession,
|
||||
mcp_session_factory,
|
||||
) -> None:
|
||||
"""Ensures POST /mcp accepts an initialize JSON-RPC request."""
|
||||
initialize_result = await mcp_session_uninitialized.initialize()
|
||||
async with mcp_session_factory(initialize=False) as mcp_session_uninitialized:
|
||||
initialize_result = await mcp_session_uninitialized.initialize()
|
||||
|
||||
assert initialize_result.protocolVersion
|
||||
assert initialize_result.serverInfo.name
|
||||
|
||||
Reference in New Issue
Block a user