@@ -183,6 +183,15 @@ def test_batch_allows_post_with_json_encoding(client):
183
183
}]
184
184
185
185
186
+ def test_batch_fails_if_is_empty (client ):
187
+ response = client .post (batch_url_string (), '[]' , 'application/json' )
188
+
189
+ assert response .status_code == 400
190
+ assert response_json (response ) == {
191
+ 'errors' : [{'message' : 'Received an empty list in the batch request.' }]
192
+ }
193
+
194
+
186
195
def test_allows_sending_a_mutation_via_post (client ):
187
196
response = client .post (url_string (), j (query = 'mutation TestMutation { writeTest { test } }' ), 'application/json' )
188
197
@@ -432,9 +441,18 @@ def test_handles_errors_caused_by_a_lack_of_query(client):
432
441
}
433
442
434
443
435
- def test_handles_invalid_json_bodies (client ):
444
+ def test_handles_not_expected_json_bodies (client ):
436
445
response = client .post (url_string (), '[]' , 'application/json' )
437
446
447
+ assert response .status_code == 400
448
+ assert response_json (response ) == {
449
+ 'errors' : [{'message' : 'The received data is not a valid JSON query.' }]
450
+ }
451
+
452
+
453
+ def test_handles_invalid_json_bodies (client ):
454
+ response = client .post (url_string (), '[oh}' , 'application/json' )
455
+
438
456
assert response .status_code == 400
439
457
assert response_json (response ) == {
440
458
'errors' : [{'message' : 'POST body sent invalid JSON.' }]
0 commit comments