def test_get_handler_chain_registered_for_event_request(self): test_intent_request = mock.MagicMock(spec=IntentRequest) test_request_envelope = mock.MagicMock(spec=RequestEnvelope) test_request_envelope.request = test_intent_request test_handler_input = HandlerInput( request_envelope=test_request_envelope) test_intent_handler = mock.MagicMock(spec=AbstractRequestHandler) test_intent_handler.can_handle.return_value = False test_intent_request_handler_chain = RequestHandlerChain( request_handler=test_intent_handler) test_event_handler = mock.MagicMock(spec=AbstractRequestHandler) test_event_handler.can_handle.return_value = True test_event_request_handler_chain = RequestHandlerChain( request_handler=test_event_handler) test_request_mapper = RequestMapper( request_handler_chains=[ test_event_request_handler_chain, test_intent_request_handler_chain]) assert test_request_mapper.get_request_handler_chain( test_handler_input).request_handler == test_event_handler, ( "get_request_handler_chain in Request Mapper found incorrect " "request handler chain for " "intent request")
def test_no_handler_registered_for_event_request(self): test_event_request = mock.MagicMock(spec=SkillEnabledRequest) test_request_envelope = mock.MagicMock(spec=RequestEnvelope) test_request_envelope.request = test_event_request test_handler_input = HandlerInput( request_envelope=test_request_envelope) test_request_handler = mock.MagicMock(spec=AbstractRequestHandler) test_request_handler.can_handle.return_value = False test_request_handler_chain = RequestHandlerChain( request_handler=test_request_handler) test_request_mapper = RequestMapper( request_handler_chains=[test_request_handler_chain]) assert test_request_mapper.get_request_handler_chain(test_handler_input) is None, ( "get_request_handler_chain in Request Mapper found an unsupported " "request handler chain for " "event request")