From 4958eeb3ef4fb2bc1748f2595f6e865749eae148 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sun, 21 Jun 2026 17:51:16 -0500 Subject: [PATCH] connection tests --- tests/web/test_endpoint_connections.py | 62 ++++++++++++++++++++++++++ tests/web/test_mcp_endpoints.py | 35 --------------- 2 files changed, 62 insertions(+), 35 deletions(-) create mode 100644 tests/web/test_endpoint_connections.py delete mode 100644 tests/web/test_mcp_endpoints.py diff --git a/tests/web/test_endpoint_connections.py b/tests/web/test_endpoint_connections.py new file mode 100644 index 0000000..28eb794 --- /dev/null +++ b/tests/web/test_endpoint_connections.py @@ -0,0 +1,62 @@ +from __future__ import annotations + +import pytest +from fastapi.testclient import TestClient +from mcp import ClientSession + +pytestmark = pytest.mark.smoke + + +class TestMcpHttpEndpoints: + """Covers smoke-level HTTP checks for mounted MCP runtime endpoints.""" + + class TestHealthz: + """Covers health endpoint smoke behavior.""" + + def test_returns_ok_payload(self, client: TestClient) -> None: + """Ensures GET /healthz responds with a healthy status payload.""" + response = client.get("/healthz") + + assert response.status_code == 200 + assert response.json() == {"status": "ok"} + + class TestDocsRoute: + """Covers static docs route smoke behavior.""" + + def test_serves_docs_entrypoint(self, client: TestClient) -> None: + """Ensures GET /docs returns the docs site entrypoint response.""" + response = client.get("/docs") + + 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_rejects_get_stream_without_support( + self, + client: TestClient, + mcp_session: ClientSession, + ) -> None: + """Ensures GET /mcp returns method not allowed for current transport mode.""" + response = client.get( + "/mcp", + headers={"Accept": "text/event-stream"}, + ) + + # 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, + ) -> None: + """Ensures POST /mcp accepts an initialize JSON-RPC request.""" + initialize_result = await mcp_session_uninitialized.initialize() + + assert initialize_result.protocolVersion + assert initialize_result.serverInfo.name diff --git a/tests/web/test_mcp_endpoints.py b/tests/web/test_mcp_endpoints.py deleted file mode 100644 index a08b9df..0000000 --- a/tests/web/test_mcp_endpoints.py +++ /dev/null @@ -1,35 +0,0 @@ -from __future__ import annotations - -from typing import Any - -import pytest -from fastapi.testclient import TestClient - -pytestmark = pytest.mark.smoke - - -class TestMcpHttpEndpoints: - """Covers smoke-level HTTP checks for mounted MCP runtime endpoints.""" - - class TestHealthz: - """Covers health endpoint smoke behavior.""" - - def test_returns_ok_payload(self, client: TestClient) -> None: - """Ensures GET /healthz responds with a healthy status payload.""" - - class TestDocsRoute: - """Covers static docs route smoke behavior.""" - - def test_serves_docs_entrypoint(self, client: TestClient) -> None: - """Ensures GET /docs returns the docs site entrypoint response.""" - - class TestMcpRoute: - """Covers MCP transport endpoint smoke behavior.""" - - @pytest.mark.asyncio - async def test_rejects_get_stream_without_support(self, mcp_session: Any) -> None: - """Ensures GET /mcp returns method not allowed for current transport mode.""" - - @pytest.mark.asyncio - async def test_accepts_initialize_jsonrpc_request(self, mcp_session_uninitialized: Any) -> None: - """Ensures POST /mcp accepts an initialize JSON-RPC request."""