"""Test Exception Handler.""" import json from unittest.mock import patch from oto import response from product_digital import config @patch('product_digital.logic.hello.health_check', side_effect=Exception()) def test_exception_hanlder(patch_check, client): """An uncaught exception results in a 500 status code.""" result = client.get(config.HEALTH_CHECK) 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