@@ -76,12 +76,10 @@ async def test_reports_validation_errors(client):
76
76
{
77
77
"message" : "Cannot query field 'unknownOne' on type 'QueryRoot'." ,
78
78
"locations" : [{"line" : 1 , "column" : 9 }],
79
- "path" : None ,
80
79
},
81
80
{
82
81
"message" : "Cannot query field 'unknownTwo' on type 'QueryRoot'." ,
83
82
"locations" : [{"line" : 1 , "column" : 21 }],
84
- "path" : None ,
85
83
},
86
84
],
87
85
}
@@ -107,8 +105,6 @@ async def test_errors_when_missing_operation_name(client):
107
105
"Must provide operation name if query contains multiple "
108
106
"operations."
109
107
),
110
- "locations" : None ,
111
- "path" : None ,
112
108
},
113
109
]
114
110
}
@@ -128,8 +124,6 @@ async def test_errors_when_sending_a_mutation_via_get(client):
128
124
"errors" : [
129
125
{
130
126
"message" : "Can only perform a mutation operation from a POST request." ,
131
- "locations" : None ,
132
- "path" : None ,
133
127
},
134
128
],
135
129
}
@@ -152,8 +146,6 @@ async def test_errors_when_selecting_a_mutation_within_a_get(client):
152
146
"errors" : [
153
147
{
154
148
"message" : "Can only perform a mutation operation from a POST request." ,
155
- "locations" : None ,
156
- "path" : None ,
157
149
},
158
150
],
159
151
}
@@ -174,10 +166,8 @@ async def test_errors_when_selecting_a_subscription_within_a_get(client):
174
166
assert await response .json () == {
175
167
"errors" : [
176
168
{
177
- "message" : "Can only perform a subscription operation from a POST "
178
- "request." ,
179
- "locations" : None ,
180
- "path" : None ,
169
+ "message" : "Can only perform a subscription operation"
170
+ " from a POST request." ,
181
171
},
182
172
],
183
173
}
@@ -215,7 +205,11 @@ async def test_allows_post_with_json_encoding(client):
215
205
async def test_allows_sending_a_mutation_via_post (client ):
216
206
response = await client .post (
217
207
"/graphql" ,
218
- data = json .dumps (dict (query = "mutation TestMutation { writeTest { test } }" ,)),
208
+ data = json .dumps (
209
+ dict (
210
+ query = "mutation TestMutation { writeTest { test } }" ,
211
+ )
212
+ ),
219
213
headers = {"content-type" : "application/json" },
220
214
)
221
215
@@ -292,7 +286,11 @@ async def test_supports_post_url_encoded_query_with_string_variables(client):
292
286
async def test_supports_post_json_quey_with_get_variable_values (client ):
293
287
response = await client .post (
294
288
url_string (variables = json .dumps ({"who" : "Dolly" })),
295
- data = json .dumps (dict (query = "query helloWho($who: String){ test(who: $who) }" ,)),
289
+ data = json .dumps (
290
+ dict (
291
+ query = "query helloWho($who: String){ test(who: $who) }" ,
292
+ )
293
+ ),
296
294
headers = {"content-type" : "application/json" },
297
295
)
298
296
@@ -304,7 +302,11 @@ async def test_supports_post_json_quey_with_get_variable_values(client):
304
302
async def test_post_url_encoded_query_with_get_variable_values (client ):
305
303
response = await client .post (
306
304
url_string (variables = json .dumps ({"who" : "Dolly" })),
307
- data = urlencode (dict (query = "query helloWho($who: String){ test(who: $who) }" ,)),
305
+ data = urlencode (
306
+ dict (
307
+ query = "query helloWho($who: String){ test(who: $who) }" ,
308
+ )
309
+ ),
308
310
headers = {"content-type" : "application/x-www-form-urlencoded" },
309
311
)
310
312
@@ -421,7 +423,6 @@ async def test_handles_syntax_errors_caught_by_graphql(client):
421
423
{
422
424
"locations" : [{"column" : 1 , "line" : 1 }],
423
425
"message" : "Syntax Error: Unexpected Name 'syntaxerror'." ,
424
- "path" : None ,
425
426
},
426
427
],
427
428
}
@@ -433,25 +434,23 @@ async def test_handles_errors_caused_by_a_lack_of_query(client):
433
434
434
435
assert response .status == 400
435
436
assert await response .json () == {
436
- "errors" : [
437
- {"message" : "Must provide query string." , "locations" : None , "path" : None }
438
- ]
437
+ "errors" : [{"message" : "Must provide query string." }]
439
438
}
440
439
441
440
442
441
@pytest .mark .asyncio
443
442
async def test_handles_batch_correctly_if_is_disabled (client ):
444
443
response = await client .post (
445
- "/graphql" , data = "[]" , headers = {"content-type" : "application/json" },
444
+ "/graphql" ,
445
+ data = "[]" ,
446
+ headers = {"content-type" : "application/json" },
446
447
)
447
448
448
449
assert response .status == 400
449
450
assert await response .json () == {
450
451
"errors" : [
451
452
{
452
453
"message" : "Batch GraphQL requests are not enabled." ,
453
- "locations" : None ,
454
- "path" : None ,
455
454
}
456
455
]
457
456
}
@@ -460,16 +459,16 @@ async def test_handles_batch_correctly_if_is_disabled(client):
460
459
@pytest .mark .asyncio
461
460
async def test_handles_incomplete_json_bodies (client ):
462
461
response = await client .post (
463
- "/graphql" , data = '{"query":' , headers = {"content-type" : "application/json" },
462
+ "/graphql" ,
463
+ data = '{"query":' ,
464
+ headers = {"content-type" : "application/json" },
464
465
)
465
466
466
467
assert response .status == 400
467
468
assert await response .json () == {
468
469
"errors" : [
469
470
{
470
471
"message" : "POST body sent invalid JSON." ,
471
- "locations" : None ,
472
- "path" : None ,
473
472
}
474
473
]
475
474
}
@@ -484,9 +483,7 @@ async def test_handles_plain_post_text(client):
484
483
)
485
484
assert response .status == 400
486
485
assert await response .json () == {
487
- "errors" : [
488
- {"message" : "Must provide query string." , "locations" : None , "path" : None }
489
- ]
486
+ "errors" : [{"message" : "Must provide query string." }]
490
487
}
491
488
492
489
@@ -499,9 +496,7 @@ async def test_handles_poorly_formed_variables(client):
499
496
)
500
497
assert response .status == 400
501
498
assert await response .json () == {
502
- "errors" : [
503
- {"message" : "Variables are invalid JSON." , "locations" : None , "path" : None }
504
- ]
499
+ "errors" : [{"message" : "Variables are invalid JSON." }]
505
500
}
506
501
507
502
@@ -514,8 +509,6 @@ async def test_handles_unsupported_http_methods(client):
514
509
"errors" : [
515
510
{
516
511
"message" : "GraphQL only supports GET and POST requests." ,
517
- "locations" : None ,
518
- "path" : None ,
519
512
}
520
513
]
521
514
}
@@ -576,16 +569,15 @@ async def test_post_multipart_data(client):
576
569
577
570
data = (
578
571
"------aiohttpgraphql\r \n "
579
- + 'Content-Disposition: form-data; name="query"\r \n '
580
- + "\r \n "
581
- + query
582
- + "\r \n "
583
- + "------aiohttpgraphql--\r \n "
584
- + "Content-Type: text/plain; charset=utf-8\r \n "
585
- + 'Content-Disposition: form-data; name="file"; filename="text1.txt"; filename*=utf-8\' \' text1.txt\r \n ' # noqa: ignore
586
- + "\r \n "
587
- + "\r \n "
588
- + "------aiohttpgraphql--\r \n "
572
+ 'Content-Disposition: form-data; name="query"\r \n '
573
+ "\r \n " + query + "\r \n "
574
+ "------aiohttpgraphql--\r \n "
575
+ "Content-Type: text/plain; charset=utf-8\r \n "
576
+ 'Content-Disposition: form-data; name="file"; filename="text1.txt";'
577
+ " filename*=utf-8''text1.txt\r \n "
578
+ "\r \n "
579
+ "\r \n "
580
+ "------aiohttpgraphql--\r \n "
589
581
)
590
582
591
583
response = await client .post (
@@ -595,7 +587,7 @@ async def test_post_multipart_data(client):
595
587
)
596
588
597
589
assert response .status == 200
598
- assert await response .json () == {"data" : {u "writeTest" : {u "test" : u "Hello World" }}}
590
+ assert await response .json () == {"data" : {"writeTest" : {"test" : "Hello World" }}}
599
591
600
592
601
593
@pytest .mark .asyncio
@@ -674,7 +666,8 @@ async def test_async_schema(app, client):
674
666
@pytest .mark .asyncio
675
667
async def test_preflight_request (client ):
676
668
response = await client .options (
677
- "/graphql" , headers = {"Access-Control-Request-Method" : "POST" },
669
+ "/graphql" ,
670
+ headers = {"Access-Control-Request-Method" : "POST" },
678
671
)
679
672
680
673
assert response .status == 200
@@ -683,7 +676,8 @@ async def test_preflight_request(client):
683
676
@pytest .mark .asyncio
684
677
async def test_preflight_incorrect_request (client ):
685
678
response = await client .options (
686
- "/graphql" , headers = {"Access-Control-Request-Method" : "OPTIONS" },
679
+ "/graphql" ,
680
+ headers = {"Access-Control-Request-Method" : "OPTIONS" },
687
681
)
688
682
689
683
assert response .status == 400
0 commit comments