Skip to content

Commit e3a1d66

Browse files
Fatima ArkinFatima Arkin
authored andcommitted
add NoopASGI and clean tests
1 parent 2e10b1d commit e3a1d66

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/shared/test_sse.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from pydantic import AnyUrl
1111
from starlette.applications import Starlette
1212
from starlette.requests import Request
13-
from starlette.responses import Response
1413
from starlette.routing import Mount, Route
1514

1615
import mcp.types as types
@@ -31,6 +30,7 @@
3130
TextResourceContents,
3231
Tool,
3332
)
33+
from tests.test_helpers import NoopASGI
3434

3535
SERVER_NAME = "test_server_for_SSE"
3636
TEST_SERVER_HOST = "testserver"
@@ -92,10 +92,10 @@ def create_sse_app(server: Server) -> Starlette:
9292
)
9393
sse = SseServerTransport("/messages/", security_settings=security_settings)
9494

95-
async def handle_sse(request: Request) -> Response:
95+
async def handle_sse(request: Request) -> NoopASGI:
9696
async with sse.connect_sse(request.scope, request.receive, request._send) as streams:
9797
await server.run(streams[0], streams[1], server.create_initialization_options())
98-
return Response()
98+
return NoopASGI()
9999

100100
return Starlette(
101101
routes=[
@@ -135,7 +135,7 @@ async def sse_client_session(tg: TaskGroup, server_app: Starlette) -> AsyncGener
135135
asgi_client_factory = create_asgi_client_factory(server_app, tg)
136136

137137
async with sse_client(
138-
f"{TEST_SERVER_BASE_URL}/sse",
138+
"/sse",
139139
httpx_client_factory=asgi_client_factory,
140140
) as streams:
141141
async with ClientSession(*streams) as session:
@@ -240,7 +240,7 @@ async def sse_client_mounted_server_app_session(
240240
asgi_client_factory = create_asgi_client_factory(mounted_server_app, tg)
241241

242242
async with sse_client(
243-
f"{TEST_SERVER_BASE_URL}/mounted_app/sse",
243+
"/mounted_app/sse",
244244
httpx_client_factory=asgi_client_factory,
245245
) as streams:
246246
async with ClientSession(*streams) as session:
@@ -323,7 +323,7 @@ async def test_request_context_propagation(tg: TaskGroup, context_server_app: St
323323
asgi_client_factory = create_asgi_client_factory(context_server_app, tg)
324324

325325
async with sse_client(
326-
f"{TEST_SERVER_BASE_URL}/sse",
326+
"/sse",
327327
headers=custom_headers,
328328
httpx_client_factory=asgi_client_factory,
329329
) as streams:
@@ -358,7 +358,7 @@ async def test_request_context_isolation(tg: TaskGroup, context_server_app: Star
358358
headers = {"X-Request-Id": f"request-{i}", "X-Custom-Value": f"value-{i}"}
359359

360360
async with sse_client(
361-
f"{TEST_SERVER_BASE_URL}/sse",
361+
"/sse",
362362
headers=headers,
363363
httpx_client_factory=asgi_client_factory,
364364
) as streams:

0 commit comments

Comments
 (0)