def test_add_request_handler_chain_throw_error_for_null_chain(self): test_exception_mapper = GenericExceptionMapper(exception_handlers=None) with self.assertRaises(DispatchException) as exc: test_exception_mapper.add_exception_handler(None) assert "Input is not an AbstractExceptionHandler instance" in str( exc.exception ), ("Exception Mapper didn't throw error during add_exception_handler " "method call when " "an invalid Exception Handler is passed")
def test_add_exception_handler_for_valid_handler_type(self): test_exception_handler = mock.MagicMock(spec=AbstractExceptionHandler) test_exception_mapper = GenericExceptionMapper(exception_handlers=None) test_exception_mapper.add_exception_handler(test_exception_handler) assert test_exception_mapper.exception_handlers == [ test_exception_handler ], ("Exception Mapper throws exception when a valid Exception Handler " "is provided in the " "add_handler method")