improved error 415 (#1185)

* improved error 415

* test added

* Fix tests for updated 415 error response

Co-authored-by: unknown <parthsujalshah@gmail.com.com>
Co-authored-by: Ruwan <ruwanlambrichts@gmail.com>
This commit is contained in:
Parth Shah
2021-11-05 01:21:16 +05:30
committed by GitHub
parent 7aeb3bdfb7
commit fc6803bc00
4 changed files with 37 additions and 1 deletions

View File

@@ -78,3 +78,11 @@ def test_errors(problem_app):
problem_as_exception_body = json.loads(problem_as_exception.data.decode('utf-8', 'replace'))
assert 'age' in problem_as_exception_body
assert problem_as_exception_body['age'] == 30
unsupported_media_type = app_client.post('/v1.0/post_wrong_content_type', data='<html></html>', content_type='text/html')
assert unsupported_media_type.status_code == 415
unsupported_media_type_body = json.loads(unsupported_media_type.data.decode('utf-8', 'replace'))
assert unsupported_media_type_body['type'] == 'about:blank'
assert unsupported_media_type_body['title'] == 'Unsupported Media Type'
assert unsupported_media_type_body['detail'] == 'Invalid Content-type (text/html), expected JSON data'
assert unsupported_media_type_body['status'] == 415