@@ -83,9 +83,11 @@ async def handler(request):
8383
8484 query = gql (query1_str )
8585
86- with pytest .raises (TransportServerError ):
86+ with pytest .raises (TransportServerError ) as exc_info :
8787 await session .execute (query )
8888
89+ assert "500, message='Internal Server Error'" in str (exc_info .value )
90+
8991
9092query1_server_error_answer = '{"errors": ["Error 1", "Error 2"]}'
9193
@@ -114,15 +116,34 @@ async def handler(request):
114116
115117
116118invalid_protocol_responses = [
117- "{}" ,
118- "qlsjfqsdlkj" ,
119- '{"not_data_or_errors": 35}' ,
119+ {
120+ "response" : "{}" ,
121+ "expected_exception" : (
122+ "Server did not return a GraphQL result: "
123+ 'No "data" or "error" keys in answer: {}'
124+ ),
125+ },
126+ {
127+ "response" : "qlsjfqsdlkj" ,
128+ "expected_exception" : (
129+ "Server did not return a GraphQL result: " "qlsjfqsdlkj"
130+ ),
131+ },
132+ {
133+ "response" : '{"not_data_or_errors": 35}' ,
134+ "expected_exception" : (
135+ "Server did not return a GraphQL result: "
136+ 'No "data" or "error" keys in answer: {"not_data_or_errors": 35}'
137+ ),
138+ },
120139]
121140
122141
123142@pytest .mark .asyncio
124- @pytest .mark .parametrize ("response" , invalid_protocol_responses )
125- async def test_aiohttp_invalid_protocol (event_loop , aiohttp_server , response ):
143+ @pytest .mark .parametrize ("param" , invalid_protocol_responses )
144+ async def test_aiohttp_invalid_protocol (event_loop , aiohttp_server , param ):
145+ response = param ["response" ]
146+
126147 async def handler (request ):
127148 return web .Response (text = response , content_type = "application/json" )
128149
@@ -138,9 +159,11 @@ async def handler(request):
138159
139160 query = gql (query1_str )
140161
141- with pytest .raises (TransportProtocolError ):
162+ with pytest .raises (TransportProtocolError ) as exc_info :
142163 await session .execute (query )
143164
165+ assert param ["expected_exception" ] in str (exc_info .value )
166+
144167
145168@pytest .mark .asyncio
146169async def test_aiohttp_subscribe_not_supported (event_loop , aiohttp_server ):
0 commit comments