Skip to content

Commit 392c1ae

Browse files
committed
Improved batch view tests
1 parent b9ebb99 commit 392c1ae

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

graphene_django/tests/test_views.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def test_batch_allows_post_with_json_encoding(client):
184184

185185

186186
def test_batch_fails_if_is_empty(client):
187-
response = client.post(batch_url_string(), j([]), 'application/json')
187+
response = client.post(batch_url_string(), '[]', 'application/json')
188188

189-
assert response.status_code == 200
189+
assert response.status_code == 400
190190
assert response_json(response) == {
191191
'errors': [{'message': 'Received an empty list in the batch request.'}]
192192
}
@@ -441,9 +441,18 @@ def test_handles_errors_caused_by_a_lack_of_query(client):
441441
}
442442

443443

444-
def test_handles_invalid_json_bodies(client):
444+
def test_handles_not_expected_json_bodies(client):
445445
response = client.post(url_string(), '[]', 'application/json')
446446

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+
447456
assert response.status_code == 400
448457
assert response_json(response) == {
449458
'errors': [{'message': 'POST body sent invalid JSON.'}]

0 commit comments

Comments
 (0)