web tests

This commit is contained in:
John Lancaster
2026-06-21 17:57:01 -05:00
parent 4958eeb3ef
commit b9bb11ac02
11 changed files with 242 additions and 20 deletions
+9 -7
View File
@@ -1,7 +1,7 @@
from __future__ import annotations
import pytest
from fastapi.testclient import TestClient
from httpx import AsyncClient
from mcp import ClientSession
pytestmark = pytest.mark.smoke
@@ -13,9 +13,10 @@ class TestMcpHttpEndpoints:
class TestHealthz:
"""Covers health endpoint smoke behavior."""
def test_returns_ok_payload(self, client: TestClient) -> None:
@pytest.mark.asyncio
async def test_returns_ok_payload(self, client: AsyncClient) -> None:
"""Ensures GET /healthz responds with a healthy status payload."""
response = client.get("/healthz")
response = await client.get("/healthz")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
@@ -23,9 +24,10 @@ class TestMcpHttpEndpoints:
class TestDocsRoute:
"""Covers static docs route smoke behavior."""
def test_serves_docs_entrypoint(self, client: TestClient) -> None:
@pytest.mark.asyncio
async def test_serves_docs_entrypoint(self, client: AsyncClient) -> None:
"""Ensures GET /docs returns the docs site entrypoint response."""
response = client.get("/docs")
response = await client.get("/docs")
assert response.status_code == 200
assert "text/html" in response.headers["content-type"]
@@ -36,11 +38,11 @@ class TestMcpHttpEndpoints:
@pytest.mark.asyncio
async def test_rejects_get_stream_without_support(
self,
client: TestClient,
client: AsyncClient,
mcp_session: ClientSession,
) -> None:
"""Ensures GET /mcp returns method not allowed for current transport mode."""
response = client.get(
response = await client.get(
"/mcp",
headers={"Accept": "text/event-stream"},
)