Skip to content

Commit

Permalink
Fix tests for updated 415 response
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwann committed Jul 20, 2021
1 parent de75c5c commit 0e17292
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/api/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ def test_errors(problem_app):
assert 'age' in problem_as_exception_body
assert problem_as_exception_body['age'] == 30

unsupported_media_type = app_client.get('/v1.0/media_type_not_supported')
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['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
assert unsupported_media_type_body['instance'] == 'instance1'
12 changes: 12 additions & 0 deletions tests/fixtures/problem/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ paths:
responses:
'200':
description: Problem exception
/post_wrong_content_type:
post:
description: Unsupported media type
operationId: fakeapi.hello.post_wrong_content_type
requestBody:
content:
application/json:
schema:
type: object
responses:
200:
description: OK
servers:
- url: /v1.0
components:
Expand Down
16 changes: 16 additions & 0 deletions tests/fixtures/problem/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,19 @@ paths:
responses:
200:
description: Problem exception

/post_wrong_content_type:
post:
description: Unsupported media type
operationId: fakeapi.hello.post_wrong_content_type
consumes:
- application/json
parameters:
- in: body
name: body
description: The request body
schema:
type: object
responses:
200:
description: OK

0 comments on commit 0e17292

Please sign in to comment.