def testErrorHandlerCanProcessInternalServerError(self): """Test error handler can process HTTP error.""" error_500 = exceptions.InternalServerError() resp = error_handler.handle_error(error_500) resp_obj = json.loads(resp.data[len(ufo.XSSI_PREFIX):]) self.assertEqual(error_500.code, resp_obj['code']) self.assertEqual(error_500.description, resp_obj['message'])
def ErrorHandlerCanProcessCustomError(self): """Test error handler can process custom error.""" setup_needed_error = SetupNeeded() werkzeug_error = exceptions.InternalServerError(SetupNeeded.message) resp = error_handler.handle_error(setup_needed_error) self.assertEqual(werkzeug_error.code, resp[1]) self.assertTrue(str(werkzeug_error.code) in resp[0].data) self.assertTrue(werkzeug_error.message in resp[0].data)
def ErrorHandlerCanProcessCustomError(self): """Test error handler can process custom error.""" setup_needed_error = SetupNeeded() werkzeug_error = exceptions.InternalServerError( SetupNeeded.message) resp = error_handler.handle_error(setup_needed_error) self.assertEqual(werkzeug_error.code, resp[1]) self.assertTrue(str(werkzeug_error.code) in resp[0].data) self.assertTrue(werkzeug_error.message in resp[0].data)