Skip to content

Commit

Permalink
Add test to ensure on_valid content types work as anticiptated
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Feb 3, 2016
1 parent 888e973 commit c37e7f9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_output_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ def render(self):
assert hug.output_format.avi_video(FakeVideoWithSave(), hug.Response()) == 'test'


def test_on_valid():
'''Test to ensure formats that use on_valid content types gracefully handle error dictionaries'''
error_dict = {'errors': {'so': 'many'}}
expected = hug.output_format.json(error_dict)

assert hug.output_format.mp4_video(error_dict, hug.Response()) == expected
assert hug.output_format.png_image(error_dict, hug.Response()) == expected


def test_on_content_type():
'''Ensure that it's possible to route the output type format by the requested content-type'''
formatter = hug.output_format.on_content_type({'application/json': hug.output_format.json,
Expand Down

0 comments on commit c37e7f9

Please sign in to comment.