"""Tests for Handlers.""" import json from unittest.mock import MagicMock from flask import current_app from owsresponse import response from werkzeug.exceptions import InternalServerError def test_exception_handler(): """Verify exception_Handler returns 500 status code and json payload.""" message = ( 'The server encountered an internal error ' 'and was unable to complete your request.' ) mock_error = MagicMock() error_handlers = current_app.error_handler_spec[None] server_response = error_handlers[500][InternalServerError](mock_error) # assert status code is 500 assert server_response.status_code == 500 # assert json payload response_message = json.loads(server_response.data.decode()) assert response_message['message'] == message assert response_message['code'] == response.error.ERROR_CODE_INTERNAL_ERROR