diff --git a/test/unittests/skills/test_intent_service.py b/test/unittests/skills/test_intent_service.py index 1ea7c43a15ce..a6862e9e9fea 100644 --- a/test/unittests/skills/test_intent_service.py +++ b/test/unittests/skills/test_intent_service.py @@ -93,115 +93,6 @@ def check_converse_request(message, skill_id): message.data['skill_id'] == skill_id) -class ConversationTest(TestCase): - def setUp(self): - bus = mock.Mock() - self.intent_service = IntentService(bus) - self.intent_service.converse.activate_skill('c64_skill') - self.intent_service.converse.activate_skill('atari_skill') - - def _collect(message=None): - return self.intent_service.converse.get_active_skills() - - self.intent_service.converse._collect_converse_skills = _collect - - def test_converse(self): - """Check that the _converse method reports if the utterance is handled. - - Also check that the skill that handled the query is moved to the - top of the active skill list. - """ - def response(message, return_msg_type): - c64 = Message(return_msg_type, {'skill_id': 'c64_skill', - 'result': False}) - atari = Message(return_msg_type, {'skill_id': 'atari_skill', - 'result': True}) - msgs = {'c64_skill': c64, 'atari_skill': atari} - LOG.debug(f'message: {message.serialize()}') - return msgs[message.data['skill_id']] - - self.intent_service.converse.bus.wait_for_response.side_effect = response - - hello = ['hello old friend'] - utterance_msg = Message('recognizer_loop:utterance', - data={'lang': 'en-US', - 'utterances': hello}) - #self.assertEqual(self.intent_service.converse.get_active_skills(), ['c64_skill', 'atari_skill']) - result = self.intent_service.converse.converse_with_skills(hello, "en-US", utterance_msg) - self.intent_service.converse.activate_skill(result.skill_id) - # Check that the active skill list was updated to set the responding - # Skill first. - self.assertEqual(self.intent_service.converse.active_skills[0][0], 'atari_skill') - - # Check that a skill responded that it could handle the message - self.assertTrue(result) - - def test_converse_error(self): - """Check that all skill IDs in the active_skills list are called. - even if there's an error. - """ - def response(message, return_msg_type): - c64 = Message(return_msg_type, {'skill_id': 'c64_skill', - 'result': False}) - amiga = Message(return_msg_type, - {'skill_id': 'amiga_skill', - 'error': 'skill id does not exist'}) - atari = Message(return_msg_type, {'skill_id': 'atari_skill', - 'result': False}) - msgs = {'c64_skill': c64, - 'atari_skill': atari, - 'amiga_skill': amiga} - - return msgs.get(message.data['skill_id']) - - self.intent_service.converse.activate_skill('amiga_skill') - self.intent_service.bus.wait_for_response.side_effect = response - - hello = ['hello old friend'] - utterance_msg = Message('recognizer_loop:utterance', - data={'lang': 'en-US', - 'utterances': hello}) - result = self.intent_service.converse.converse_with_skills(hello, 'en-US', utterance_msg) - - # Check that the active skill list was updated to set the responding - # Skill first. - - # Check that a skill responded that it couldn't handle the message - self.assertFalse(result) - - # Check that each skill in the list of active skills were called - call_args = self.intent_service.bus.wait_for_response.call_args_list - sent_skill_ids = [call[0][0].data['skill_id'] for call in call_args] - self.assertEqual(sent_skill_ids, - ['amiga_skill', 'c64_skill', 'atari_skill']) - - def test_reset_converse(self): - """Check that a blank stt sends the reset signal to the skills.""" - def response(message, return_msg_type): - c64 = Message(return_msg_type, - {'skill_id': 'c64_skill', - 'error': 'skill id does not exist'}) - atari = Message(return_msg_type, {'skill_id': 'atari_skill', - 'result': False}) - msgs = {'c64_skill': c64, 'atari_skill': atari} - - return msgs.get(message.data['skill_id'], None) - - reset_msg = Message('mycroft.speech.recognition.unknown', - data={'lang': 'en-US'}) - self.intent_service.bus.wait_for_response.side_effect = response - - self.intent_service.reset_converse(reset_msg) - # Check send messages - wait_for_response_mock = self.intent_service.bus.wait_for_response - c64_message = wait_for_response_mock.call_args_list[0][0][0] - self.assertTrue(check_converse_request(c64_message, 'c64_skill')) - atari_message = wait_for_response_mock.call_args_list[1][0][0] - self.assertTrue(check_converse_request(atari_message, 'atari_skill')) - #first_active_skill = self.intent_service.active_skills[0][0] - #self.assertEqual(first_active_skill, 'atari_skill') - - class TestLanguageExtraction(TestCase): @mock.patch.dict(Configuration._Configuration__patch, BASE_CONF) def test_no_lang_in_message(self):