@@ -88,17 +88,16 @@ async def handler(request):
8888
8989
9090@pytest .mark .asyncio
91- async def test_aiohttp_query_with_extensions (aiohttp_server ):
91+ async def test_aiohttp_request_extensions (aiohttp_server ):
9292 from aiohttp import web
9393
9494 from gql .transport .aiohttp import AIOHTTPTransport
9595
96+ extensions = {"persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }}
97+
9698 async def handler (request ):
9799 body = await request .json ()
98- assert "extensions" in body
99- assert body ["extensions" ] == {
100- "persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }
101- }
100+ assert body ["extensions" ] == extensions
102101 return web .Response (
103102 text = query1_server_answer ,
104103 content_type = "application/json" ,
@@ -112,19 +111,17 @@ async def handler(request):
112111
113112 transport = AIOHTTPTransport (url = url , timeout = 10 )
114113
115- async with Client ( transport = transport ) as session :
114+ request = GraphQLRequest ( query1_str , extensions = extensions )
116115
117- request = GraphQLRequest (
118- query1_str ,
119- extensions = {
120- "persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }
121- },
122- )
116+ async with Client (transport = transport ) as session :
123117
118+ # execute
124119 result = await session .execute (request )
120+ assert result ["continents" ][0 ]["code" ] == "AF"
125121
126- continents = result ["continents" ]
127- assert continents [0 ]["code" ] == "AF"
122+ # subscribe
123+ async for result in session .subscribe (request ):
124+ assert result ["continents" ][0 ]["code" ] == "AF"
128125
129126
130127@pytest .mark .asyncio
@@ -619,46 +616,6 @@ def test_code():
619616 await run_sync_test (server , test_code )
620617
621618
622- @pytest .mark .asyncio
623- async def test_aiohttp_subscribe_with_extensions (aiohttp_server ):
624- from aiohttp import web
625-
626- from gql .transport .aiohttp import AIOHTTPTransport
627-
628- async def handler (request ):
629- body = await request .json ()
630- assert "extensions" in body
631- assert body ["extensions" ] == {
632- "persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }
633- }
634- return web .Response (
635- text = query1_server_answer ,
636- content_type = "application/json" ,
637- )
638-
639- app = web .Application ()
640- app .router .add_route ("POST" , "/" , handler )
641- server = await aiohttp_server (app )
642-
643- url = server .make_url ("/" )
644-
645- transport = AIOHTTPTransport (url = url , timeout = 10 )
646-
647- request = GraphQLRequest (
648- query1_str ,
649- extensions = {"persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }},
650- )
651-
652- async with Client (transport = transport ) as session :
653-
654- results = []
655- async for result in session .subscribe (request ):
656- results .append (result )
657-
658- assert len (results ) == 1
659- assert results [0 ]["continents" ][0 ]["code" ] == "AF"
660-
661-
662619file_upload_mutation_1 = """
663620 mutation($file: Upload!) {
664621 uploadFile(input:{other_var:$other_var, file:$file}) {
0 commit comments