"""Test Exception Handler.""" import json from unittest.mock import patch from oto import response from product_workflow import config @patch('product_workflow.logic.hello.health_check', side_effect=Exception()) def test_exception_hanlder(patch_check, client, valid_headers): """An uncaught exception results in a 500 status code.""" result = client.get(config.HEALTH_CHECK, headers=valid_headers) response_message = json.loads(result.data.decode()) expected_message = ( 'The server encountered an internal error ' 'and was unable to complete your request.') assert result.status_code == 500 assert response_message['message'] == expected_message assert response_message['code'] == response.error.ERROR_CODE_INTERNAL_ERROR