def test_generic_handler_chain_add_response_interceptors_to_empty_list(self): test_handler = mock.Mock() test_handler_chain = GenericRequestHandlerChain( request_handler=test_handler) test_response_interceptor = mock.Mock() test_handler_chain.add_response_interceptor( interceptor=test_response_interceptor) assert test_handler_chain.response_interceptors == [test_response_interceptor], ( "Generic Request Handler Chain didn't add interceptor to list of " "response interceptors when no " "response interceptors are provided during instantiation")
def test_generic_handler_chain_instantiate_call_parent_instantiation(self): test_handler = mock.Mock() test_handler_chain = GenericRequestHandlerChain( request_handler=test_handler) assert test_handler_chain.request_interceptors == [] and test_handler_chain.response_interceptors == [], ( "Default Request Handler Chain didn't call parent instantiation " "method during init")
def test_generic_handler_chain_add_response_interceptors_to_non_empty_list(self): test_handler = mock.Mock() test_interceptor_1 = mock.MagicMock(spec=AbstractResponseInterceptor) test_interceptors = [test_interceptor_1] test_handler_chain = GenericRequestHandlerChain( request_handler=test_handler, response_interceptors=test_interceptors) test_response_interceptor = mock.MagicMock( spec=AbstractResponseInterceptor) test_handler_chain.add_response_interceptor( interceptor=test_response_interceptor) assert test_handler_chain.response_interceptors == [ test_interceptor_1, test_response_interceptor], ( "Generic Request Handler Chain didn't add interceptor to list of " "response interceptors when " "response interceptors are provided during instantiation")
def test_generic_handler_chain_instantiate_response_interceptors(self): test_handler = mock.Mock() test_handler_chain = GenericRequestHandlerChain( request_handler=test_handler) assert test_handler_chain.response_interceptors == [], ( "Generic Request Handler Chain didn't instantiate empty list of " "response interceptors when no " "response interceptors are provided during instantiation")
def test_generic_handler_chain_with_null_request_handler_throws_error(self): with self.assertRaises(DispatchException) as exc: test_handler_chain = GenericRequestHandlerChain( request_handler=None) assert "No Request Handler provided" in str(exc.exception), ( "Generic Request Handler Chain didn't raise exception when no " "request handler is provided during " "instantiation")