@@ -183,6 +183,15 @@ def test_batch_allows_post_with_json_encoding(client):
183183 }]
184184
185185
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+
186195def test_allows_sending_a_mutation_via_post (client ):
187196 response = client .post (url_string (), j (query = 'mutation TestMutation { writeTest { test } }' ), 'application/json' )
188197
@@ -432,9 +441,18 @@ def test_handles_errors_caused_by_a_lack_of_query(client):
432441 }
433442
434443
435- def test_handles_invalid_json_bodies (client ):
444+ def test_handles_not_expected_json_bodies (client ):
436445 response = client .post (url_string (), '[]' , 'application/json' )
437446
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+
438456 assert response .status_code == 400
439457 assert response_json (response ) == {
440458 'errors' : [{'message' : 'POST body sent invalid JSON.' }]
0 commit comments