@@ -142,11 +142,6 @@ async def error_handler(request):
142142
143143 return app
144144
145- @pytest_asyncio .fixture
146- async def aiohttp_client (aiohttp_client , app ):
147- """Create a test client for our app."""
148- return await aiohttp_client (app )
149-
150145
151146@pytest_asyncio .fixture
152147async def http_transport ():
@@ -155,48 +150,52 @@ async def http_transport():
155150
156151
157152@pytest_asyncio .fixture
158- async def http_call_template (aiohttp_client ):
153+ async def http_call_template (aiohttp_client , app ):
159154 """Create a basic HTTP call template for testing."""
155+ client = await aiohttp_client (app )
160156 return HttpCallTemplate (
161157 name = "test_call_template" ,
162- url = f"http://localhost:{ aiohttp_client .port } /tools" ,
158+ url = f"http://localhost:{ client .port } /tools" ,
163159 http_method = "GET"
164160 )
165161
166162
167163@pytest_asyncio .fixture
168- async def api_key_call_template (aiohttp_client ):
164+ async def api_key_call_template (aiohttp_client , app ):
169165 """Create an HTTP call template with API key auth."""
166+ client = await aiohttp_client (app )
170167 return HttpCallTemplate (
171168 name = "api-key-call-template" ,
172- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
169+ url = f"http://localhost:{ client .port } /tool" ,
173170 http_method = "GET" ,
174171 auth = ApiKeyAuth (api_key = "test-api-key" , var_name = "X-API-Key" , location = "header" )
175172 )
176173
177174
178175@pytest_asyncio .fixture
179- async def basic_auth_call_template (aiohttp_client ):
176+ async def basic_auth_call_template (aiohttp_client , app ):
180177 """Create an HTTP call template with Basic auth."""
178+ client = await aiohttp_client (app )
181179 return HttpCallTemplate (
182180 name = "basic-auth-call-template" ,
183- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
181+ url = f"http://localhost:{ client .port } /tool" ,
184182 http_method = "GET" ,
185183 auth = BasicAuth (username = "user" , password = "pass" )
186184 )
187185
188186
189187@pytest_asyncio .fixture
190- async def oauth2_call_template (aiohttp_client ):
188+ async def oauth2_call_template (aiohttp_client , app ):
191189 """Create an HTTP call template with OAuth2 auth."""
190+ client = await aiohttp_client (app )
192191 return HttpCallTemplate (
193192 name = "oauth2-call-template" ,
194- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
193+ url = f"http://localhost:{ client .port } /tool" ,
195194 http_method = "GET" ,
196195 auth = OAuth2Auth (
197196 client_id = "client-id" ,
198197 client_secret = "client-secret" ,
199- token_url = f"http://localhost:{ aiohttp_client .port } /token" ,
198+ token_url = f"http://localhost:{ client .port } /token" ,
200199 scope = "read write"
201200 )
202201 )
@@ -232,12 +231,13 @@ async def test_register_manual(http_transport: HttpCommunicationProtocol, http_c
232231
233232# Test error handling when registering a manual
234233@pytest .mark .asyncio
235- async def test_register_manual_http_error (http_transport , aiohttp_client ):
234+ async def test_register_manual_http_error (http_transport , aiohttp_client , app ):
236235 """Test error handling when registering a manual."""
237236 # Create a call template that points to our error endpoint
237+ client = await aiohttp_client (app )
238238 error_call_template = HttpCallTemplate (
239239 name = "error-call-template" ,
240- url = f"http://localhost:{ aiohttp_client .port } /error" ,
240+ url = f"http://localhost:{ client .port } /error" ,
241241 http_method = "GET"
242242 )
243243
@@ -263,12 +263,13 @@ async def test_deregister_manual(http_transport, http_call_template):
263263
264264# Test call_tool_basic
265265@pytest .mark .asyncio
266- async def test_call_tool_basic (http_transport , http_call_template , aiohttp_client ):
266+ async def test_call_tool_basic (http_transport , http_call_template , aiohttp_client , app ):
267267 """Test calling a tool with basic configuration."""
268268 # Update call template URL to point to our /tool endpoint
269+ client = await aiohttp_client (app )
269270 tool_call_template = HttpCallTemplate (
270271 name = http_call_template .name ,
271- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
272+ url = f"http://localhost:{ client .port } /tool" ,
272273 http_method = "GET"
273274 )
274275
@@ -314,17 +315,18 @@ async def test_call_tool_with_oauth2(http_transport, oauth2_call_template):
314315
315316
316317@pytest .mark .asyncio
317- async def test_call_tool_with_oauth2_header_auth (http_transport , aiohttp_client ):
318+ async def test_call_tool_with_oauth2_header_auth (http_transport , aiohttp_client , app ):
318319 """Test calling a tool with OAuth2 authentication (credentials in header)."""
319320 # This call template points to an endpoint that expects Basic Auth for the token
321+ client = await aiohttp_client (app )
320322 oauth2_header_call_template = HttpCallTemplate (
321323 name = "oauth2-header-call-template" ,
322- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
324+ url = f"http://localhost:{ client .port } /tool" ,
323325 http_method = "GET" ,
324326 auth = OAuth2Auth (
325327 client_id = "client-id" ,
326328 client_secret = "client-secret" ,
327- token_url = f"http://localhost:{ aiohttp_client .port } /token_header_auth" ,
329+ token_url = f"http://localhost:{ client .port } /token_header_auth" ,
328330 scope = "read write"
329331 )
330332 )
@@ -339,12 +341,13 @@ async def test_call_tool_with_oauth2_header_auth(http_transport, aiohttp_client)
339341
340342# Test call_tool_with_body_field
341343@pytest .mark .asyncio
342- async def test_call_tool_with_body_field (http_transport , aiohttp_client ):
344+ async def test_call_tool_with_body_field (http_transport , aiohttp_client , app ):
343345 """Test calling a tool with a body field."""
344346 # Create call template with body field
347+ client = await aiohttp_client (app )
345348 call_template = HttpCallTemplate (
346349 name = "body-field-call-template" ,
347- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
350+ url = f"http://localhost:{ client .port } /tool" ,
348351 http_method = "POST" ,
349352 body_field = "data"
350353 )
@@ -363,12 +366,13 @@ async def test_call_tool_with_body_field(http_transport, aiohttp_client):
363366
364367# Test call_tool_with_path_params
365368@pytest .mark .asyncio
366- async def test_call_tool_with_path_params (http_transport , aiohttp_client ):
369+ async def test_call_tool_with_path_params (http_transport , aiohttp_client , app ):
367370 """Test calling a tool with path parameters."""
368371 # Create call template with path params in URL
372+ client = await aiohttp_client (app )
369373 call_template = HttpCallTemplate (
370374 name = "path-params-call-template" ,
371- url = f"http://localhost:{ aiohttp_client .port } /tool/{{param1}}" ,
375+ url = f"http://localhost:{ client .port } /tool/{{param1}}" ,
372376 http_method = "GET"
373377 )
374378
@@ -386,12 +390,13 @@ async def test_call_tool_with_path_params(http_transport, aiohttp_client):
386390
387391# Test call_tool_with_custom_headers
388392@pytest .mark .asyncio
389- async def test_call_tool_with_custom_headers (http_transport , aiohttp_client ):
393+ async def test_call_tool_with_custom_headers (http_transport , aiohttp_client , app ):
390394 """Test calling a tool with custom headers."""
391395 # Create call template with custom headers
396+ client = await aiohttp_client (app )
392397 call_template = HttpCallTemplate (
393398 name = "custom-headers-call-template" ,
394- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
399+ url = f"http://localhost:{ client .port } /tool" ,
395400 http_method = "GET" ,
396401 additional_headers = {"X-Custom-Header" : "custom-value" }
397402 )
@@ -527,11 +532,12 @@ async def path_param_handler(request):
527532
528533
529534@pytest .mark .asyncio
530- async def test_call_tool_streaming_basic (http_transport , http_call_template , aiohttp_client ):
535+ async def test_call_tool_streaming_basic (http_transport , http_call_template , aiohttp_client , app ):
531536 """Streaming basic call should yield one result identical to call_tool."""
537+ client = await aiohttp_client (app )
532538 tool_call_template = HttpCallTemplate (
533539 name = http_call_template .name ,
534- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
540+ url = f"http://localhost:{ client .port } /tool" ,
535541 http_method = "GET" ,
536542 )
537543 stream = http_transport .call_tool_streaming (None , "test_tool" , {"param1" : "value1" }, tool_call_template )
@@ -564,16 +570,17 @@ async def test_call_tool_streaming_with_oauth2(http_transport, oauth2_call_templ
564570
565571
566572@pytest .mark .asyncio
567- async def test_call_tool_streaming_with_oauth2_header_auth (http_transport , aiohttp_client ):
573+ async def test_call_tool_streaming_with_oauth2_header_auth (http_transport , aiohttp_client , app ):
568574 """Streaming with OAuth2 (credentials in header) yields one aggregated result."""
575+ client = await aiohttp_client (app )
569576 oauth2_header_call_template = HttpCallTemplate (
570577 name = "oauth2-header-call-template" ,
571- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
578+ url = f"http://localhost:{ client .port } /tool" ,
572579 http_method = "GET" ,
573580 auth = OAuth2Auth (
574581 client_id = "client-id" ,
575582 client_secret = "client-secret" ,
576- token_url = f"http://localhost:{ aiohttp_client .port } /token_header_auth" ,
583+ token_url = f"http://localhost:{ client .port } /token_header_auth" ,
577584 scope = "read write" ,
578585 ),
579586 )
@@ -583,11 +590,12 @@ async def test_call_tool_streaming_with_oauth2_header_auth(http_transport, aioht
583590
584591
585592@pytest .mark .asyncio
586- async def test_call_tool_streaming_with_body_field (http_transport , aiohttp_client ):
593+ async def test_call_tool_streaming_with_body_field (http_transport , aiohttp_client , app ):
587594 """Streaming POST with body_field yields one aggregated result."""
595+ client = await aiohttp_client (app )
588596 call_template = HttpCallTemplate (
589597 name = "body-field-call-template" ,
590- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
598+ url = f"http://localhost:{ client .port } /tool" ,
591599 http_method = "POST" ,
592600 body_field = "data" ,
593601 )
@@ -602,11 +610,12 @@ async def test_call_tool_streaming_with_body_field(http_transport, aiohttp_clien
602610
603611
604612@pytest .mark .asyncio
605- async def test_call_tool_streaming_with_path_params (http_transport , aiohttp_client ):
613+ async def test_call_tool_streaming_with_path_params (http_transport , aiohttp_client , app ):
606614 """Streaming with URL path params yields one aggregated result."""
615+ client = await aiohttp_client (app )
607616 call_template = HttpCallTemplate (
608617 name = "path-params-call-template" ,
609- url = f"http://localhost:{ aiohttp_client .port } /tool/{{param1}}" ,
618+ url = f"http://localhost:{ client .port } /tool/{{param1}}" ,
610619 http_method = "GET" ,
611620 )
612621 stream = http_transport .call_tool_streaming (
@@ -620,11 +629,12 @@ async def test_call_tool_streaming_with_path_params(http_transport, aiohttp_clie
620629
621630
622631@pytest .mark .asyncio
623- async def test_call_tool_streaming_with_custom_headers (http_transport , aiohttp_client ):
632+ async def test_call_tool_streaming_with_custom_headers (http_transport , aiohttp_client , app ):
624633 """Streaming with additional headers yields one aggregated result."""
634+ client = await aiohttp_client (app )
625635 call_template = HttpCallTemplate (
626636 name = "custom-headers-call-template" ,
627- url = f"http://localhost:{ aiohttp_client .port } /tool" ,
637+ url = f"http://localhost:{ client .port } /tool" ,
628638 http_method = "GET" ,
629639 additional_headers = {"X-Custom-Header" : "custom-value" },
630640 )
0 commit comments