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
+10 -6
View File
@@ -2,11 +2,10 @@ from __future__ import annotations
import os
from collections.abc import AsyncIterator
from collections.abc import Iterator
import pytest
import pytest_asyncio
from fastapi.testclient import TestClient
from httpx import ASGITransport
from httpx import AsyncClient
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
@@ -14,10 +13,15 @@ from mcp.client.streamable_http import streamable_http_client
from personal_mcp.web.app import create_app
@pytest.fixture
def client() -> Iterator[TestClient]:
"""Provides a TestClient bound to a fresh application instance."""
with TestClient(create_app()) as test_client:
@pytest_asyncio.fixture
async def client() -> AsyncIterator[AsyncClient]:
"""Provides an AsyncClient bound to a fresh application instance."""
app = create_app()
async with AsyncClient(
transport=ASGITransport(app=app),
base_url="http://testserver",
timeout=10.0,
) as test_client:
yield test_client