mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-25 16:15:16 +03:00
Rewrite unit test to make it working on all versions of django
This commit is contained in:
parent
a9f34dab93
commit
33b2b42e6f
|
@ -457,14 +457,18 @@ def test_handles_invalid_json_bodies(client):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_handles_django_request_error(client, settings):
|
def test_handles_django_request_error(client, monkeypatch):
|
||||||
settings.DATA_UPLOAD_MAX_MEMORY_SIZE = 1000
|
def mocked_read(*args):
|
||||||
valid_json = json.dumps(dict(test='x' * 1000))
|
raise IOError("foo-bar")
|
||||||
|
|
||||||
|
monkeypatch.setattr("django.http.request.HttpRequest.read", mocked_read)
|
||||||
|
|
||||||
|
valid_json = json.dumps(dict(foo='bar'))
|
||||||
response = client.post(url_string(), valid_json, 'application/json')
|
response = client.post(url_string(), valid_json, 'application/json')
|
||||||
|
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
assert response_json(response) == {
|
assert response_json(response) == {
|
||||||
'errors': [{'message': 'Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.'}]
|
'errors': [{'message': 'foo-bar'}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user