web tests
This commit is contained in:
+10
-6
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user