@@ -83,9 +83,11 @@ async def handler(request):
83
83
84
84
query = gql (query1_str )
85
85
86
- with pytest .raises (TransportServerError ):
86
+ with pytest .raises (TransportServerError ) as exc_info :
87
87
await session .execute (query )
88
88
89
+ assert "500, message='Internal Server Error'" in str (exc_info .value )
90
+
89
91
90
92
query1_server_error_answer = '{"errors": ["Error 1", "Error 2"]}'
91
93
@@ -114,15 +116,34 @@ async def handler(request):
114
116
115
117
116
118
invalid_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
+ },
120
139
]
121
140
122
141
123
142
@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
+
126
147
async def handler (request ):
127
148
return web .Response (text = response , content_type = "application/json" )
128
149
@@ -138,9 +159,11 @@ async def handler(request):
138
159
139
160
query = gql (query1_str )
140
161
141
- with pytest .raises (TransportProtocolError ):
162
+ with pytest .raises (TransportProtocolError ) as exc_info :
142
163
await session .execute (query )
143
164
165
+ assert param ["expected_exception" ] in str (exc_info .value )
166
+
144
167
145
168
@pytest .mark .asyncio
146
169
async def test_aiohttp_subscribe_not_supported (event_loop , aiohttp_server ):
0 commit comments