Skip to content

Commit 33b2b42

Browse files
committed
Rewrite unit test to make it working on all versions of django
1 parent a9f34da commit 33b2b42

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

graphene_django/tests/test_views.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,18 @@ def test_handles_invalid_json_bodies(client):
457457
}
458458

459459

460-
def test_handles_django_request_error(client, settings):
461-
settings.DATA_UPLOAD_MAX_MEMORY_SIZE = 1000
462-
valid_json = json.dumps(dict(test='x' * 1000))
460+
def test_handles_django_request_error(client, monkeypatch):
461+
def mocked_read(*args):
462+
raise IOError("foo-bar")
463+
464+
monkeypatch.setattr("django.http.request.HttpRequest.read", mocked_read)
465+
466+
valid_json = json.dumps(dict(foo='bar'))
463467
response = client.post(url_string(), valid_json, 'application/json')
464468

465469
assert response.status_code == 400
466470
assert response_json(response) == {
467-
'errors': [{'message': 'Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.'}]
471+
'errors': [{'message': 'foo-bar'}]
468472
}
469473

470474

0 commit comments

Comments
 (0)