diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index 509f22d7a94..79fed0a3406 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -295,8 +295,19 @@ def _emit_match_message(self, match: IntentMatch, message: Message): # keep all original message.data and update with intent match data = dict(message.data) data.update(match.intent_data) + # NOTE: message.reply to ensure correct message destination reply = message.reply(match.intent_type, data) + + # let's activate the skill BEFORE the intent is triggered + # to ensure an accurate Session + # NOTE: this was previously done async by the skill, + # but then the skill was missing from Session.active_skills + sess = self.converse.activate_skill(message=reply, + skill_id=match.skill_id) + if sess: + reply.context["session"] = sess.serialize() + self.bus.emit(reply) def send_cancel_event(self, message): diff --git a/ovos_core/intent_services/converse_service.py b/ovos_core/intent_services/converse_service.py index d44ae3bdcf0..f85e7e2c929 100644 --- a/ovos_core/intent_services/converse_service.py +++ b/ovos_core/intent_services/converse_service.py @@ -105,6 +105,7 @@ def activate_skill(self, skill_id, source_skill=None, message=None): self.bus.emit(message) # update activation counter self._consecutive_activations[skill_id] += 1 + return session def _activate_allowed(self, skill_id, source_skill=None): """Checks if a skill_id is allowed to jump to the front of active skills list diff --git a/ovos_core/intent_services/ocp_service.py b/ovos_core/intent_services/ocp_service.py index e5afcc865e2..6132e396793 100644 --- a/ovos_core/intent_services/ocp_service.py +++ b/ovos_core/intent_services/ocp_service.py @@ -730,7 +730,6 @@ def match_high(self, utterances: List[str], lang: str, message: Message = None): else: return None - self.activate() # mark skill_id as active, this is a catch all for all OCP skills return ovos_core.intent_services.IntentMatch(intent_service="OCP_intents", intent_type=f'ocp:{match["name"]}', intent_data=match, @@ -756,7 +755,6 @@ def match_medium(self, utterances: List[str], lang: str, message: Message = None # extract the query string query = self.remove_voc(utterance, "Play", lang).strip() - self.activate() # mark skill_id as active, this is a catch all for all OCP skills return ovos_core.intent_services.IntentMatch(intent_service="OCP_media", intent_type=f"ocp:play", intent_data={"media_type": media_type, @@ -783,7 +781,7 @@ def match_fallback(self, utterances: List[str], lang: str, message: Message = No # extract the query string query = self.remove_voc(utterance, "Play", lang).strip() - self.activate() # mark skill_id as active, this is a catch all for all OCP skills + return ovos_core.intent_services.IntentMatch(intent_service="OCP_fallback", intent_type=f"ocp:play", intent_data={"media_type": media_type, @@ -796,8 +794,6 @@ def match_fallback(self, utterances: List[str], lang: str, message: Message = No def _process_play_query(self, utterance: str, lang: str, match: dict = None, message: Optional[Message] = None): - self.activate() # mark skill_id as active, this is a catch all for all OCP skills - match = match or {} player = self.get_player(message) # if media is currently paused, empty string means "resume playback" @@ -820,8 +816,6 @@ def _process_play_query(self, utterance: str, lang: str, match: dict = None, skill_id=OCP_ID, utterance=utterance) - self.speak_dialog("just.one.moment") - sess = SessionManager.get(message) # if a skill was explicitly requested, search it first valid_skills = [ @@ -888,6 +882,9 @@ def handle_play_favorites_intent(self, message: Message): # intent handlers def handle_play_intent(self, message: Message): + + self.speak_dialog("just.one.moment") + lang = message.data["lang"] query = message.data["query"] media_type = message.data["media_type"] @@ -1412,8 +1409,6 @@ def match_legacy(self, utterances: List[str], lang: str, message: Message = None return None if match["name"] == "play": LOG.info(f"Legacy Mycroft CommonPlay match: {match}") - # we dont call self.activate , the skill itself is activated on selection - # playback is happening outside of OCP utterance = match["entities"].pop("query") return ovos_core.intent_services.IntentMatch(intent_service="OCP_media", intent_type=f"ocp:legacy_cps", diff --git a/requirements/requirements.txt b/requirements/requirements.txt index b73a9f5f2f0..048f3e8f8f4 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -12,7 +12,7 @@ ovos-plugin-manager<0.1.0, >=0.0.25 ovos-config~=0.0,>=0.0.13a8 ovos-lingua-franca>=0.4.7 ovos-backend-client~=0.1.0 -ovos-workshop<0.1.0, >=0.0.16a35 +ovos-workshop<0.1.0, >=0.0.16a36 # provides plugins and classic machine learning framework ovos-classifiers<0.1.0, >=0.0.0a53 diff --git a/test/end2end/routing/test_sched.py b/test/end2end/routing/test_sched.py index f1cc23f362f..66a6350fdce 100644 --- a/test/end2end/routing/test_sched.py +++ b/test/end2end/routing/test_sched.py @@ -47,14 +47,10 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", # no session - f"{self.skill_id}:ScheduleIntent", # intent trigger - "mycroft.skill.handler.start", # intent code start - - "intent.service.skills.activate", # request (from workshop) "intent.service.skills.activated", # response (from core) f"{self.skill_id}.activate", # skill callback - "ovos.session.update_default", # session update (active skill list ync) - + f"{self.skill_id}:ScheduleIntent", # intent trigger + "mycroft.skill.handler.start", # intent code start "enclosure.active_skill", "speak", "mycroft.scheduler.schedule_event", @@ -72,16 +68,18 @@ def wait_for_n_messages(n): self.assertEqual(len(expected_messages), len(messages)) - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) + for idx, m in enumerate(messages): + self.assertEqual(m.msg_type, expected_messages[idx]) # verify that source and destination are swapped after intent trigger - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:ScheduleIntent") + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:ScheduleIntent") for m in messages: - if m.msg_type in ["recognizer_loop:utterance", "ovos.session.update_default"]: + # messages FOR ovos-core + if m.msg_type in ["recognizer_loop:utterance", + "ovos.session.update_default"]: self.assertEqual(messages[0].context["source"], "A") self.assertEqual(messages[0].context["destination"], "B") + # messages FROM ovos-core else: self.assertEqual(m.context["source"], "B") self.assertEqual(m.context["destination"], "A") diff --git a/test/end2end/routing/test_session.py b/test/end2end/routing/test_session.py index 934d4415de7..989892792d9 100644 --- a/test/end2end/routing/test_session.py +++ b/test/end2end/routing/test_session.py @@ -50,12 +50,10 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", # no session - f"{self.skill_id}:HelloWorldIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", + f"{self.skill_id}:HelloWorldIntent", + "mycroft.skill.handler.start", "enclosure.active_skill", "speak", "mycroft.skill.handler.complete", @@ -66,9 +64,8 @@ def wait_for_n_messages(n): self.assertEqual(len(expected_messages), len(messages)) - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) + for idx, m in enumerate(messages): + self.assertEqual(m.msg_type, expected_messages[idx]) # verify that "session" is injected # (missing in utterance message) and kept in all messages @@ -76,7 +73,7 @@ def wait_for_n_messages(n): self.assertEqual(m.context["session"]["session_id"], "default") # verify that source and destination are swapped after intent trigger - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:HelloWorldIntent") + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:HelloWorldIntent") for m in messages: if m.msg_type in ["recognizer_loop:utterance", "ovos.session.update_default"]: self.assertEqual(messages[0].context["source"], "A") diff --git a/test/end2end/session/test_blacklist.py b/test/end2end/session/test_blacklist.py index 78743591ffd..4407558bd6b 100644 --- a/test/end2end/session/test_blacklist.py +++ b/test/end2end/session/test_blacklist.py @@ -58,11 +58,10 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", # skill selected - f"{self.skill_id}:HelloWorldIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", + f"{self.skill_id}:HelloWorldIntent", + "mycroft.skill.handler.start", # skill code executing "enclosure.active_skill", "speak", @@ -76,7 +75,7 @@ def wait_for_n_messages(n): self.assertEqual(m.msg_type, expected_messages[idx]) # sanity check correct intent triggered - self.assertEqual(messages[7].data["meta"]["dialog"], "hello.world") + self.assertEqual(messages[-3].data["meta"]["dialog"], "hello.world") ######################################## # skill in blacklist @@ -176,12 +175,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -222,12 +220,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -267,12 +264,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search diff --git a/test/end2end/session/test_converse.py b/test/end2end/session/test_converse.py index 98ed733b01d..25dd0e2c087 100644 --- a/test/end2end/session/test_converse.py +++ b/test/end2end/session/test_converse.py @@ -59,14 +59,12 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", # no session + "intent.service.skills.activated", + f"{self.skill_id}.activate", # skill selected f"{self.skill_id}:converse_off.intent", # skill triggering "mycroft.skill.handler.start", - "intent.service.skills.activate", - "intent.service.skills.activated", - f"{self.skill_id}.activate", - "ovos.session.update_default", # intent code executing "enclosure.active_skill", "speak", @@ -88,31 +86,22 @@ def wait_for_n_messages(n): self.assertEqual(m.context["session"]["session_id"], "default") self.assertEqual(m.context["lang"], "en-us") + # verify skill is activated + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:converse_off.intent") - # verify skill_id is now present in every message.context + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:converse_off.intent") + # verify skill_id is present in every message.context for m in messages[1:]: self.assertEqual(m.context["skill_id"], self.skill_id) - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "TestAbortSkill.handle_converse_off") - # verify skill is activated - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") # verify intent execution - self.assertEqual(messages[7].msg_type, "enclosure.active_skill") - self.assertEqual(messages[7].data["skill_id"], self.skill_id) - self.assertEqual(messages[8].msg_type, "speak") - self.assertEqual(messages[8].data["lang"], "en-us") - self.assertFalse(messages[8].data["expect_response"]) - self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[9].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[9].data["name"], "TestAbortSkill.handle_converse_off") - self.assertEqual(messages[10].msg_type, "ovos.utterance.handled") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "TestAbortSkill.handle_converse_off") + self.assertEqual(messages[-3].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[-3].data["name"], "TestAbortSkill.handle_converse_off") + self.assertEqual(messages[-2].msg_type, "ovos.utterance.handled") # verify default session is now updated self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") self.assertEqual(messages[-1].data["session_data"]["session_id"], "default") @@ -143,13 +132,10 @@ def wait_for_n_messages(n): f"{self.skill_id}.converse.request", "skill.converse.response", # does not want to converse # skill selected - f"{self.other_skill_id}:HelloWorldIntent", - "mycroft.skill.handler.start", - # skill activated - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.other_skill_id}.activate", - "ovos.session.update_default", + f"{self.other_skill_id}:HelloWorldIntent", + "mycroft.skill.handler.start", # skill executing "enclosure.active_skill", "speak", @@ -187,35 +173,25 @@ def wait_for_n_messages(n): self.assertEqual(messages[4].data["skill_id"], self.skill_id) self.assertFalse(messages[4].data["result"]) # does not want to converse + # verify skill is activated + self.assertEqual(messages[5].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[5].data["skill_id"], self.other_skill_id) + self.assertEqual(messages[6].msg_type, f"{self.other_skill_id}.activate") # verify intent triggers - self.assertEqual(messages[5].msg_type, f"{self.other_skill_id}:HelloWorldIntent") - # verify skill_id is now present in every message.context + self.assertEqual(messages[7].msg_type, f"{self.other_skill_id}:HelloWorldIntent") + # verify skill_id is present in every message.context for m in messages[5:]: self.assertEqual(m.context["skill_id"], self.other_skill_id) - self.assertEqual(messages[6].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[6].data["name"], "HelloWorldSkill.handle_hello_world_intent") - - # verify skill is activated - self.assertEqual(messages[7].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[7].data["skill_id"], self.other_skill_id) - self.assertEqual(messages[8].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[8].data["skill_id"], self.other_skill_id) - self.assertEqual(messages[9].msg_type, f"{self.other_skill_id}.activate") - self.assertEqual(messages[10].msg_type, "ovos.session.update_default") + self.assertEqual(messages[8].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[8].data["name"], "HelloWorldSkill.handle_hello_world_intent") # verify intent execution - self.assertEqual(messages[11].msg_type, "enclosure.active_skill") - self.assertEqual(messages[11].data["skill_id"], self.other_skill_id) - self.assertEqual(messages[12].msg_type, "speak") - self.assertEqual(messages[12].data["lang"], "en-us") - self.assertFalse(messages[12].data["expect_response"]) - self.assertEqual(messages[12].data["meta"]["skill"], self.other_skill_id) - self.assertEqual(messages[13].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[13].data["name"], "HelloWorldSkill.handle_hello_world_intent") + self.assertEqual(messages[-3].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[-3].data["name"], "HelloWorldSkill.handle_hello_world_intent") # verify default session is now updated - self.assertEqual(messages[14].msg_type, "ovos.utterance.handled") + self.assertEqual(messages[-2].msg_type, "ovos.utterance.handled") self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") self.assertEqual(messages[-1].data["session_data"]["session_id"], "default") # test deserialization of payload @@ -249,11 +225,8 @@ def wait_for_n_messages(n): f"{self.skill_id}.converse.request", "skill.converse.response", # does not want to converse # skill selected - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", - f"{self.skill_id}:converse_on.intent", # skill executing "mycroft.skill.handler.start", @@ -294,35 +267,26 @@ def wait_for_n_messages(n): self.assertEqual(messages[6].data["skill_id"], self.skill_id) self.assertFalse(messages[6].data["result"]) # do not want to converse + # verify skill is activated by intent service (intent pipeline matched) + self.assertEqual(messages[7].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[7].data["skill_id"], self.skill_id) + self.assertEqual(messages[8].msg_type, f"{self.skill_id}.activate") + # verify intent triggers - self.assertEqual(messages[7].msg_type, f"{self.skill_id}:converse_on.intent") + self.assertEqual(messages[9].msg_type, f"{self.skill_id}:converse_on.intent") # verify skill_id is now present in every message.context for m in messages[7:]: self.assertEqual(m.context["skill_id"], self.skill_id) # verify intent execution - self.assertEqual(messages[8].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[8].data["name"], "TestAbortSkill.handle_converse_on") + self.assertEqual(messages[10].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[10].data["name"], "TestAbortSkill.handle_converse_on") - # verify skill is activated by intent service (intent pipeline matched) - self.assertEqual(messages[9].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[9].data["skill_id"], self.skill_id) - self.assertEqual(messages[10].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[10].data["skill_id"], self.skill_id) - self.assertEqual(messages[11].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[12].msg_type, "ovos.session.update_default") - - self.assertEqual(messages[13].msg_type, "enclosure.active_skill") - self.assertEqual(messages[13].data["skill_id"], self.skill_id) - self.assertEqual(messages[14].msg_type, "speak") - self.assertEqual(messages[14].data["lang"], "en-us") - self.assertFalse(messages[14].data["expect_response"]) - self.assertEqual(messages[14].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[15].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[15].data["name"], "TestAbortSkill.handle_converse_on") + self.assertEqual(messages[-3].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[-3].data["name"], "TestAbortSkill.handle_converse_on") # verify default session is now updated - self.assertEqual(messages[16].msg_type, "ovos.utterance.handled") + self.assertEqual(messages[-2].msg_type, "ovos.utterance.handled") self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") self.assertEqual(messages[-1].data["session_data"]["session_id"], "default") # test deserialization of payload @@ -507,13 +471,11 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", # no session + "intent.service.skills.activated", + f"{self.skill_id}.activate", "ovos-tskill-abort.openvoiceos:deactivate.intent", # skill selected "mycroft.skill.handler.start", - "intent.service.skills.activate", - "intent.service.skills.activated", - f"{self.skill_id}.activate", - "ovos.session.update_default", # intent code "intent.service.skills.deactivate", "intent.service.skills.deactivated", diff --git a/test/end2end/session/test_get_response.py b/test/end2end/session/test_get_response.py index ae48bdbe990..eed18255fdb 100644 --- a/test/end2end/session/test_get_response.py +++ b/test/end2end/session/test_get_response.py @@ -62,13 +62,10 @@ def on_speak(msg): expected_messages = [ "recognizer_loop:utterance", # trigger intent to start the test # skill selected - f"{self.skill_id}:test_get_response.intent", - "mycroft.skill.handler.start", - # skill activated (because of selection) - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", # sync skill activation + f"{self.skill_id}:test_get_response.intent", + "mycroft.skill.handler.start", # intent code "skill.converse.get_response.enable", # start of get_response "ovos.session.update_default", # sync get_response status @@ -94,69 +91,64 @@ def on_speak(msg): self.assertEqual(len(expected_messages), len(messages)) - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) + for idx, m in enumerate(messages): + self.assertEqual(m.msg_type, expected_messages[idx]) # verify that "session" is injected # (missing in utterance message) and kept in all messages for m in messages[1:]: - print(m.msg_type, m.context["session"]["session_id"]) self.assertEqual(m.context["session"]["session_id"], "default") self.assertEqual(m.context["lang"], "en-us") # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:test_get_response.intent") + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:test_get_response.intent") # verify skill_id is now present in every message.context for m in messages[1:]: self.assertEqual(m.context["skill_id"], self.skill_id) # verify intent execution - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "TestAbortSkill.handle_test_get_response") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "TestAbortSkill.handle_test_get_response") # verify skill is activated - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # enable get_response for this session - self.assertEqual(messages[7].msg_type, "skill.converse.get_response.enable") - self.assertEqual(messages[8].msg_type, "ovos.session.update_default") + self.assertEqual(messages[5].msg_type, "skill.converse.get_response.enable") + self.assertEqual(messages[6].msg_type, "ovos.session.update_default") # question dialog - self.assertEqual(messages[9].msg_type, "enclosure.active_skill") - self.assertEqual(messages[9].data["skill_id"], self.skill_id) - self.assertEqual(messages[10].msg_type, "speak") - self.assertEqual(messages[10].data["lang"], "en-us") - self.assertTrue(messages[10].data["expect_response"]) # listen after dialog - self.assertEqual(messages[10].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[11].msg_type, "recognizer_loop:audio_output_start") - self.assertEqual(messages[12].msg_type, "recognizer_loop:audio_output_end") + self.assertEqual(messages[7].msg_type, "enclosure.active_skill") + self.assertEqual(messages[7].data["skill_id"], self.skill_id) + self.assertEqual(messages[8].msg_type, "speak") + self.assertEqual(messages[8].data["lang"], "en-us") + self.assertTrue(messages[8].data["expect_response"]) # listen after dialog + self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[9].msg_type, "recognizer_loop:audio_output_start") + self.assertEqual(messages[10].msg_type, "recognizer_loop:audio_output_end") # user response would be here # disable get_response for this session - self.assertEqual(messages[13].msg_type, "skill.converse.get_response.disable") - self.assertEqual(messages[14].msg_type, "ovos.session.update_default") + self.assertEqual(messages[11].msg_type, "skill.converse.get_response.disable") + self.assertEqual(messages[12].msg_type, "ovos.session.update_default") # post self.get_response intent code - self.assertEqual(messages[15].msg_type, "enclosure.active_skill") - self.assertEqual(messages[15].data["skill_id"], self.skill_id) - self.assertEqual(messages[16].msg_type, "speak") - self.assertEqual(messages[16].data["lang"], "en-us") - self.assertFalse(messages[16].data["expect_response"]) - self.assertEqual(messages[16].data["utterance"], "ERROR") - self.assertEqual(messages[16].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[13].msg_type, "enclosure.active_skill") + self.assertEqual(messages[13].data["skill_id"], self.skill_id) + self.assertEqual(messages[14].msg_type, "speak") + self.assertEqual(messages[14].data["lang"], "en-us") + self.assertFalse(messages[14].data["expect_response"]) + self.assertEqual(messages[14].data["utterance"], "ERROR") + self.assertEqual(messages[14].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[17].msg_type, "recognizer_loop:audio_output_start") - self.assertEqual(messages[18].msg_type, "recognizer_loop:audio_output_end") + self.assertEqual(messages[15].msg_type, "recognizer_loop:audio_output_start") + self.assertEqual(messages[16].msg_type, "recognizer_loop:audio_output_end") - self.assertEqual(messages[19].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[19].data["name"], "TestAbortSkill.handle_test_get_response") + self.assertEqual(messages[17].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[18].data["name"], "TestAbortSkill.handle_test_get_response") # verify default session is now updated self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") @@ -217,13 +209,10 @@ def answer_get_response(msg): expected_messages = [ "recognizer_loop:utterance", # trigger intent to start the test # skill selected - f"{self.skill_id}:test_get_response.intent", - "mycroft.skill.handler.start", - # skill activated (because of selection) - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", # sync skill activation + f"{self.skill_id}:test_get_response.intent", + "mycroft.skill.handler.start", # intent code "skill.converse.get_response.enable", # start of get_response "ovos.session.update_default", # sync get_response status @@ -256,77 +245,73 @@ def answer_get_response(msg): self.assertEqual(len(expected_messages), len(messages)) - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) + for idx, m in enumerate(messages): + self.assertEqual(m.msg_type, expected_messages[idx]) + + # verify skill is activated + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # verify that "session" is injected # (missing in utterance message) and kept in all messages for m in messages[1:]: - print(m.msg_type, m.context["session"]["session_id"]) self.assertEqual(m.context["session"]["session_id"], "default") # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:test_get_response.intent") + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:test_get_response.intent") # verify intent execution - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "TestAbortSkill.handle_test_get_response") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "TestAbortSkill.handle_test_get_response") - # verify skill is activated - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") # enable get_response for this session - self.assertEqual(messages[7].msg_type, "skill.converse.get_response.enable") - self.assertEqual(messages[8].msg_type, "ovos.session.update_default") + self.assertEqual(messages[5].msg_type, "skill.converse.get_response.enable") + self.assertEqual(messages[6].msg_type, "ovos.session.update_default") # question dialog - self.assertEqual(messages[9].msg_type, "enclosure.active_skill") - self.assertEqual(messages[9].data["skill_id"], self.skill_id) - self.assertEqual(messages[10].msg_type, "speak") - self.assertEqual(messages[10].data["utterance"], "give me an answer", ) - self.assertEqual(messages[10].data["lang"], "en-us") - self.assertTrue(messages[10].data["expect_response"]) # listen after dialog - self.assertEqual(messages[10].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[7].msg_type, "enclosure.active_skill") + self.assertEqual(messages[7].data["skill_id"], self.skill_id) + self.assertEqual(messages[8].msg_type, "speak") + self.assertEqual(messages[8].data["utterance"], "give me an answer", ) + self.assertEqual(messages[8].data["lang"], "en-us") + self.assertTrue(messages[8].data["expect_response"]) # listen after dialog + self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) # ovos-audio speak execution (simulated) - self.assertEqual(messages[11].msg_type, "recognizer_loop:audio_output_start") - self.assertEqual(messages[12].msg_type, "recognizer_loop:audio_output_end") + self.assertEqual(messages[9].msg_type, "recognizer_loop:audio_output_start") + self.assertEqual(messages[10].msg_type, "recognizer_loop:audio_output_end") # check utterance goes through converse cycle - self.assertEqual(messages[13].msg_type, "recognizer_loop:utterance") - self.assertEqual(messages[14].msg_type, f"{self.skill_id}.converse.ping") - self.assertEqual(messages[15].msg_type, "skill.converse.pong") + self.assertEqual(messages[11].msg_type, "recognizer_loop:utterance") + self.assertEqual(messages[12].msg_type, f"{self.skill_id}.converse.ping") + self.assertEqual(messages[13].msg_type, "skill.converse.pong") # captured utterance sent to get_response handler that is waiting - self.assertEqual(messages[16].msg_type, f"{self.skill_id}.converse.get_response") - self.assertEqual(messages[16].data["utterances"], ["ok"]) + self.assertEqual(messages[14].msg_type, f"{self.skill_id}.converse.get_response") + self.assertEqual(messages[14].data["utterances"], ["ok"]) # converse pipeline activates the skill last_used timestamp - self.assertEqual(messages[17].msg_type, "ovos.session.update_default") + self.assertEqual(messages[15].msg_type, "ovos.session.update_default") # disable get_response for this session - self.assertEqual(messages[18].msg_type, "skill.converse.get_response.disable") - self.assertEqual(messages[19].msg_type, "ovos.session.update_default") + self.assertEqual(messages[16].msg_type, "skill.converse.get_response.disable") + self.assertEqual(messages[17].msg_type, "ovos.session.update_default") # post self.get_response intent code - self.assertEqual(messages[20].msg_type, "enclosure.active_skill") - self.assertEqual(messages[20].data["skill_id"], self.skill_id) - self.assertEqual(messages[21].msg_type, "speak") - self.assertEqual(messages[21].data["lang"], "en-us") - self.assertFalse(messages[21].data["expect_response"]) - self.assertEqual(messages[21].data["utterance"], "ok") - self.assertEqual(messages[21].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[18].msg_type, "enclosure.active_skill") + self.assertEqual(messages[18].data["skill_id"], self.skill_id) + self.assertEqual(messages[19].msg_type, "speak") + self.assertEqual(messages[19].data["lang"], "en-us") + self.assertFalse(messages[19].data["expect_response"]) + self.assertEqual(messages[19].data["utterance"], "ok") + self.assertEqual(messages[19].data["meta"]["skill"], self.skill_id) # ovos-audio speak execution (simulated) - self.assertEqual(messages[22].msg_type, "recognizer_loop:audio_output_start") - self.assertEqual(messages[23].msg_type, "recognizer_loop:audio_output_end") + self.assertEqual(messages[20].msg_type, "recognizer_loop:audio_output_start") + self.assertEqual(messages[21].msg_type, "recognizer_loop:audio_output_end") - self.assertEqual(messages[24].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[24].data["name"], "TestAbortSkill.handle_test_get_response") + self.assertEqual(messages[22].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[22].data["name"], "TestAbortSkill.handle_test_get_response") # verify default session is now updated self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") @@ -386,13 +371,10 @@ def answer_get_response(msg): expected_messages = [ "recognizer_loop:utterance", # trigger intent to start the test # skill selected - f"{self.skill_id}:test_get_response.intent", - "mycroft.skill.handler.start", - # skill activated (because of selection) - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", # sync skill activation + f"{self.skill_id}:test_get_response.intent", + "mycroft.skill.handler.start", # intent code "skill.converse.get_response.enable", # start of get_response "ovos.session.update_default", # sync get_response status @@ -426,9 +408,8 @@ def answer_get_response(msg): self.assertEqual(len(expected_messages), len(messages)) - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) + for idx, m in enumerate(messages): + self.assertEqual(m.msg_type, expected_messages[idx]) # verify that "session" is injected # (missing in utterance message) and kept in all messages @@ -436,66 +417,63 @@ def answer_get_response(msg): self.assertEqual(m.context["session"]["session_id"], "default") # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:test_get_response.intent") + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:test_get_response.intent") # verify intent execution - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "TestAbortSkill.handle_test_get_response") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "TestAbortSkill.handle_test_get_response") # verify skill is activated - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # enable get_response for this session - self.assertEqual(messages[7].msg_type, "skill.converse.get_response.enable") - self.assertEqual(messages[8].msg_type, "ovos.session.update_default") + self.assertEqual(messages[5].msg_type, "skill.converse.get_response.enable") + self.assertEqual(messages[6].msg_type, "ovos.session.update_default") # question dialog - self.assertEqual(messages[9].msg_type, "enclosure.active_skill") - self.assertEqual(messages[9].data["skill_id"], self.skill_id) - self.assertEqual(messages[10].msg_type, "speak") - self.assertEqual(messages[10].data["utterance"], "give me an answer", ) - self.assertEqual(messages[10].data["lang"], "en-us") - self.assertTrue(messages[10].data["expect_response"]) # listen after dialog - self.assertEqual(messages[10].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[7].msg_type, "enclosure.active_skill") + self.assertEqual(messages[7].data["skill_id"], self.skill_id) + self.assertEqual(messages[8].msg_type, "speak") + self.assertEqual(messages[8].data["utterance"], "give me an answer", ) + self.assertEqual(messages[8].data["lang"], "en-us") + self.assertTrue(messages[8].data["expect_response"]) # listen after dialog + self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) # ovos-audio speak execution (simulated) - self.assertEqual(messages[11].msg_type, "recognizer_loop:audio_output_start") - self.assertEqual(messages[12].msg_type, "recognizer_loop:audio_output_end") + self.assertEqual(messages[9].msg_type, "recognizer_loop:audio_output_start") + self.assertEqual(messages[10].msg_type, "recognizer_loop:audio_output_end") # check utterance goes through converse cycle - self.assertEqual(messages[13].msg_type, "recognizer_loop:utterance") - self.assertEqual(messages[14].msg_type, f"{self.skill_id}.converse.ping") - self.assertEqual(messages[15].msg_type, "skill.converse.pong") + self.assertEqual(messages[11].msg_type, "recognizer_loop:utterance") + self.assertEqual(messages[12].msg_type, f"{self.skill_id}.converse.ping") + self.assertEqual(messages[13].msg_type, "skill.converse.pong") # captured utterance sent to get_response handler that is waiting - self.assertEqual(messages[16].msg_type, f"{self.skill_id}.converse.get_response") - self.assertEqual(messages[16].data["utterances"], ["cancel"]) # was canceled by user, returned None + self.assertEqual(messages[14].msg_type, f"{self.skill_id}.converse.get_response") + self.assertEqual(messages[14].data["utterances"], ["cancel"]) # was canceled by user, returned None # converse pipeline activates the skill last_used timestamp - self.assertEqual(messages[17].msg_type, "ovos.session.update_default") + self.assertEqual(messages[15].msg_type, "ovos.session.update_default") # disable get_response for this session - self.assertEqual(messages[18].msg_type, "skill.converse.get_response.disable") - self.assertEqual(messages[19].msg_type, "ovos.session.update_default") + self.assertEqual(messages[16].msg_type, "skill.converse.get_response.disable") + self.assertEqual(messages[17].msg_type, "ovos.session.update_default") # post self.get_response intent code - self.assertEqual(messages[20].msg_type, "enclosure.active_skill") - self.assertEqual(messages[20].data["skill_id"], self.skill_id) - self.assertEqual(messages[21].msg_type, "speak") - self.assertEqual(messages[21].data["lang"], "en-us") - self.assertFalse(messages[21].data["expect_response"]) - self.assertEqual(messages[21].data["utterance"], "ERROR") - self.assertEqual(messages[21].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[18].msg_type, "enclosure.active_skill") + self.assertEqual(messages[18].data["skill_id"], self.skill_id) + self.assertEqual(messages[19].msg_type, "speak") + self.assertEqual(messages[19].data["lang"], "en-us") + self.assertFalse(messages[19].data["expect_response"]) + self.assertEqual(messages[19].data["utterance"], "ERROR") + self.assertEqual(messages[19].data["meta"]["skill"], self.skill_id) # ovos-audio speak execution (simulated) - self.assertEqual(messages[22].msg_type, "recognizer_loop:audio_output_start") - self.assertEqual(messages[23].msg_type, "recognizer_loop:audio_output_end") + self.assertEqual(messages[20].msg_type, "recognizer_loop:audio_output_start") + self.assertEqual(messages[21].msg_type, "recognizer_loop:audio_output_end") - self.assertEqual(messages[24].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[24].data["name"], "TestAbortSkill.handle_test_get_response") + self.assertEqual(messages[22].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[22].data["name"], "TestAbortSkill.handle_test_get_response") # verify default session is now updated self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") @@ -557,13 +535,10 @@ def answer_get_response(msg): expected_messages = [ "recognizer_loop:utterance", # trigger intent to start the test # skill selected - f"{self.skill_id}:test_get_response3.intent", - "mycroft.skill.handler.start", - # skill activated (because of selection) - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", # sync skill activation + f"{self.skill_id}:test_get_response3.intent", + "mycroft.skill.handler.start", # intent code "skill.converse.get_response.enable", # start of get_response "ovos.session.update_default", # sync get_response status @@ -594,65 +569,60 @@ def answer_get_response(msg): self.assertEqual(len(expected_messages), len(messages)) - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) + for idx, m in enumerate(messages): + self.assertEqual(m.msg_type, expected_messages[idx]) # verify that "session" is injected # (missing in utterance message) and kept in all messages for m in messages[1:]: - print(m.msg_type, m.context["session"]["session_id"]) self.assertEqual(m.context["session"]["session_id"], "default") # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:test_get_response3.intent") + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:test_get_response3.intent") # verify intent execution - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "TestAbortSkill.handle_test_get_response3") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "TestAbortSkill.handle_test_get_response3") # verify skill is activated - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # enable get_response for this session - self.assertEqual(messages[7].msg_type, "skill.converse.get_response.enable") - self.assertEqual(messages[8].msg_type, "ovos.session.update_default") + self.assertEqual(messages[5].msg_type, "skill.converse.get_response.enable") + self.assertEqual(messages[6].msg_type, "ovos.session.update_default") # 3 sound prompts (no dialog in this test) + self.assertEqual(messages[7].msg_type, "mycroft.mic.listen") + self.assertEqual(messages[8].msg_type, "mycroft.mic.listen") self.assertEqual(messages[9].msg_type, "mycroft.mic.listen") - self.assertEqual(messages[10].msg_type, "mycroft.mic.listen") - self.assertEqual(messages[11].msg_type, "mycroft.mic.listen") # check utterance goes through converse cycle - self.assertEqual(messages[12].msg_type, "recognizer_loop:utterance") - self.assertEqual(messages[13].msg_type, f"{self.skill_id}.converse.ping") - self.assertEqual(messages[14].msg_type, "skill.converse.pong") + self.assertEqual(messages[10].msg_type, "recognizer_loop:utterance") + self.assertEqual(messages[11].msg_type, f"{self.skill_id}.converse.ping") + self.assertEqual(messages[12].msg_type, "skill.converse.pong") # captured utterance sent to get_response handler that is waiting - self.assertEqual(messages[15].msg_type, f"{self.skill_id}.converse.get_response") - self.assertEqual(messages[15].data["utterances"], ["ok"]) - self.assertEqual(messages[16].msg_type, "ovos.session.update_default") + self.assertEqual(messages[13].msg_type, f"{self.skill_id}.converse.get_response") + self.assertEqual(messages[13].data["utterances"], ["ok"]) + self.assertEqual(messages[14].msg_type, "ovos.session.update_default") # disable get_response for this session - self.assertEqual(messages[17].msg_type, "skill.converse.get_response.disable") - self.assertEqual(messages[18].msg_type, "ovos.session.update_default") + self.assertEqual(messages[15].msg_type, "skill.converse.get_response.disable") + self.assertEqual(messages[16].msg_type, "ovos.session.update_default") # post self.get_response intent code - self.assertEqual(messages[19].msg_type, "enclosure.active_skill") - self.assertEqual(messages[19].data["skill_id"], self.skill_id) - self.assertEqual(messages[20].msg_type, "speak") - self.assertEqual(messages[20].data["lang"], "en-us") - self.assertFalse(messages[20].data["expect_response"]) - self.assertEqual(messages[20].data["utterance"], "ok") - self.assertEqual(messages[20].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[17].msg_type, "enclosure.active_skill") + self.assertEqual(messages[17].data["skill_id"], self.skill_id) + self.assertEqual(messages[18].msg_type, "speak") + self.assertEqual(messages[18].data["lang"], "en-us") + self.assertFalse(messages[18].data["expect_response"]) + self.assertEqual(messages[18].data["utterance"], "ok") + self.assertEqual(messages[18].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[21].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[21].data["name"], "TestAbortSkill.handle_test_get_response3") + self.assertEqual(messages[19].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[19].data["name"], "TestAbortSkill.handle_test_get_response3") # verify default session is now updated self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") @@ -719,15 +689,11 @@ def answer_get_response(msg): "recognizer_loop:utterance", # no session # skill selected + "intent.service.skills.activated", + f"{self.skill_id}.activate", f"{self.skill_id}:test_get_response_cascade.intent", - - # skill activated "mycroft.skill.handler.start", - "intent.service.skills.activate", - "intent.service.skills.activated", - f"{self.skill_id}.activate", - "ovos.session.update_default", # intent code before self.get_response "enclosure.active_skill", @@ -794,9 +760,8 @@ def answer_get_response(msg): self.assertEqual(len(expected_messages), len(messages)) - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) + for idx, m in enumerate(messages): + self.assertEqual(m.msg_type, expected_messages[idx]) # verify that "session" is injected # (missing in utterance message) and kept in all messages @@ -804,32 +769,29 @@ def answer_get_response(msg): self.assertEqual(m.context["session"]["session_id"], "default") # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:test_get_response_cascade.intent") + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:test_get_response_cascade.intent") # verify intent execution - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "TestAbortSkill.handle_test_get_response_cascade") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "TestAbortSkill.handle_test_get_response_cascade") # verify skill is activated - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # post self.get_response intent code - self.assertEqual(messages[7].msg_type, "enclosure.active_skill") - self.assertEqual(messages[7].data["skill_id"], self.skill_id) - self.assertEqual(messages[8].msg_type, "speak") - self.assertEqual(messages[8].data["lang"], "en-us") - self.assertFalse(messages[8].data["expect_response"]) - self.assertEqual(messages[8].data["utterance"], "give me items") - self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[5].msg_type, "enclosure.active_skill") + self.assertEqual(messages[5].data["skill_id"], self.skill_id) + self.assertEqual(messages[6].msg_type, "speak") + self.assertEqual(messages[6].data["lang"], "en-us") + self.assertFalse(messages[6].data["expect_response"]) + self.assertEqual(messages[6].data["utterance"], "give me items") + self.assertEqual(messages[6].data["meta"]["skill"], self.skill_id) responses = ["A", "B", "C", "cancel"] for response in responses: - i = 8 + responses.index(response) * 10 + i = 6 + responses.index(response) * 10 print(i, response) # enable get_response for this session self.assertEqual(messages[i + 1].msg_type, "skill.converse.get_response.enable") @@ -855,11 +817,11 @@ def answer_get_response(msg): self.assertEqual(messages[i + 10].msg_type, "ovos.session.update_default") # intent return - self.assertEqual(messages[49].msg_type, "skill_items") - self.assertEqual(messages[49].data, {"items": ["A", "B", "C"]}) + self.assertEqual(messages[-4].msg_type, "skill_items") + self.assertEqual(messages[-4].data, {"items": ["A", "B", "C"]}) # report handler complete - self.assertEqual(messages[50].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[50].data["name"], "TestAbortSkill.handle_test_get_response_cascade") + self.assertEqual(messages[-3].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[-3].data["name"], "TestAbortSkill.handle_test_get_response_cascade") self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") diff --git a/test/end2end/session/test_ocp.py b/test/end2end/session/test_ocp.py index 89613851d3a..f8fc65dfe96 100644 --- a/test/end2end/session/test_ocp.py +++ b/test/end2end/session/test_ocp.py @@ -58,12 +58,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -128,12 +127,11 @@ def wait_for_n_messages(n): "ovos.common_play.status", "ovos.common_play.SEI.get", # request player info # no response - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -182,12 +180,11 @@ def on_get(m): "ovos.common_play.status", "ovos.common_play.SEI.get", # request player info "ovos.common_play.SEI.get.response", # OCP response - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -269,12 +266,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -344,12 +340,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -418,12 +413,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -494,12 +488,11 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", + "ocp:play", "enclosure.active_skill", "speak", - "ocp:play", "ovos.common_play.search.start", "enclosure.mouth.think", "ovos.common_play.search.stop", # any ongoing previous search @@ -572,7 +565,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:pause", @@ -632,7 +624,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:resume", @@ -692,7 +683,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:media_stop", @@ -752,7 +742,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:next", @@ -807,7 +796,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:prev", @@ -861,7 +849,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:pause", @@ -916,7 +903,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:resume", @@ -970,7 +956,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:media_stop", @@ -1025,7 +1010,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:next", @@ -1079,7 +1063,6 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", "ovos.common_play.status", - "intent.service.skills.activate", "intent.service.skills.activated", "ovos.common_play.activate", "ocp:prev", @@ -1187,6 +1170,8 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", + "intent.service.skills.activated", + "ovos.common_play.activate", "ocp:legacy_cps", # legacy cps api "play:query", @@ -1247,6 +1232,8 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", + "intent.service.skills.activated", + "ovos.common_play.activate", "ocp:legacy_cps", # legacy cps api "play:query", diff --git a/test/end2end/session/test_sched.py b/test/end2end/session/test_sched.py index e2a5ec8f355..ba08b77df4d 100644 --- a/test/end2end/session/test_sched.py +++ b/test/end2end/session/test_sched.py @@ -48,12 +48,10 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", - f"{self.skill_id}:ScheduleIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", + f"{self.skill_id}:ScheduleIntent", + "mycroft.skill.handler.start", "enclosure.active_skill", "speak", "mycroft.scheduler.schedule_event", @@ -78,60 +76,57 @@ def wait_for_n_messages(n): self.assertEqual(m.context["session"]["session_id"], "default") self.assertEqual(m.context["lang"], "en-us") - # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:ScheduleIntent") - self.assertEqual(messages[1].data["intent_type"], f"{self.skill_id}:ScheduleIntent") # verify skill_id is now present in every message.context + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") for m in messages[1:]: self.assertEqual(m.context["skill_id"], self.skill_id) + # verify intent triggers + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:ScheduleIntent") + self.assertEqual(messages[3].data["intent_type"], f"{self.skill_id}:ScheduleIntent") + # verify intent execution - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "ScheduleSkill.handle_sched_intent") - - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") - - self.assertEqual(messages[7].msg_type, "enclosure.active_skill") - self.assertEqual(messages[7].data["skill_id"], self.skill_id) - self.assertEqual(messages[8].msg_type, "speak") - self.assertEqual(messages[8].data["lang"], "en-us") - self.assertFalse(messages[8].data["expect_response"]) - self.assertEqual(messages[8].data["meta"]["dialog"], "done") - self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[9].msg_type, "mycroft.scheduler.schedule_event") - self.assertEqual(messages[10].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[10].data["name"], "ScheduleSkill.handle_sched_intent") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "ScheduleSkill.handle_sched_intent") + + self.assertEqual(messages[5].msg_type, "enclosure.active_skill") + self.assertEqual(messages[5].data["skill_id"], self.skill_id) + self.assertEqual(messages[6].msg_type, "speak") + self.assertEqual(messages[6].data["lang"], "en-us") + self.assertFalse(messages[6].data["expect_response"]) + self.assertEqual(messages[6].data["meta"]["dialog"], "done") + self.assertEqual(messages[6].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[7].msg_type, "mycroft.scheduler.schedule_event") + self.assertEqual(messages[8].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[8].data["name"], "ScheduleSkill.handle_sched_intent") # verify default session is now updated - self.assertEqual(messages[12].msg_type, "ovos.session.update_default") - self.assertEqual(messages[12].data["session_data"]["session_id"], "default") + self.assertEqual(messages[10].msg_type, "ovos.session.update_default") + self.assertEqual(messages[10].data["session_data"]["session_id"], "default") # test deserialization of payload - sess = Session.deserialize(messages[12].data["session_data"]) + sess = Session.deserialize(messages[10].data["session_data"]) self.assertEqual(sess.session_id, "default") # test that active skills list has been updated self.assertEqual(sess.active_skills[0][0], self.skill_id) - self.assertEqual(messages[12].data["session_data"]["active_skills"][0][0], self.skill_id) + self.assertEqual(messages[10].data["session_data"]["active_skills"][0][0], self.skill_id) # ensure context in triggered event is the same from message that triggered the intent - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - intent_context = messages[4].context # when skill added to active list (last context change) + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + intent_context = messages[1].context # when skill added to active list (last context change) - self.assertEqual(messages[13].msg_type, "skill-ovos-schedule.openvoiceos:my_event") + self.assertEqual(messages[11].msg_type, "skill-ovos-schedule.openvoiceos:my_event") + self.assertEqual(messages[11].context, intent_context) + self.assertEqual(messages[12].msg_type, "enclosure.active_skill") + self.assertEqual(messages[12].context, intent_context) + self.assertEqual(messages[13].msg_type, "speak") + self.assertEqual(messages[13].data["lang"], "en-us") + self.assertFalse(messages[13].data["expect_response"]) + self.assertEqual(messages[13].data["meta"]["dialog"], "trigger") + self.assertEqual(messages[13].data["meta"]["skill"], self.skill_id) self.assertEqual(messages[13].context, intent_context) - self.assertEqual(messages[14].msg_type, "enclosure.active_skill") - self.assertEqual(messages[14].context, intent_context) - self.assertEqual(messages[15].msg_type, "speak") - self.assertEqual(messages[15].data["lang"], "en-us") - self.assertFalse(messages[15].data["expect_response"]) - self.assertEqual(messages[15].data["meta"]["dialog"], "trigger") - self.assertEqual(messages[15].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[15].context, intent_context) def test_explicit_session(self): SessionManager.sessions = {} @@ -172,11 +167,10 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", - f"{self.skill_id}:ScheduleIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", + f"{self.skill_id}:ScheduleIntent", + "mycroft.skill.handler.start", "enclosure.active_skill", "speak", "mycroft.scheduler.schedule_event", @@ -199,49 +193,47 @@ def wait_for_n_messages(n): for m in messages: self.assertEqual(m.context["session"]["session_id"], sess.session_id) - # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:ScheduleIntent") - self.assertEqual(messages[1].data["intent_type"], f"{self.skill_id}:ScheduleIntent") + # verify skill is activated + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # verify skill_id is now present in every message.context for m in messages[1:]: self.assertEqual(m.context["skill_id"], self.skill_id) + # verify intent triggers + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:ScheduleIntent") + self.assertEqual(messages[3].data["intent_type"], f"{self.skill_id}:ScheduleIntent") - # verify skill is activated - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "ScheduleSkill.handle_sched_intent") - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "ScheduleSkill.handle_sched_intent") # verify intent execution - self.assertEqual(messages[6].msg_type, "enclosure.active_skill") - self.assertEqual(messages[6].data["skill_id"], self.skill_id) - self.assertEqual(messages[7].msg_type, "speak") - self.assertEqual(messages[7].data["lang"], "en-us") - self.assertFalse(messages[7].data["expect_response"]) - self.assertEqual(messages[7].data["meta"]["dialog"], "done") - self.assertEqual(messages[7].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[8].msg_type, "mycroft.scheduler.schedule_event") - self.assertEqual(messages[9].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[9].data["name"], "ScheduleSkill.handle_sched_intent") + self.assertEqual(messages[5].msg_type, "enclosure.active_skill") + self.assertEqual(messages[5].data["skill_id"], self.skill_id) + self.assertEqual(messages[6].msg_type, "speak") + self.assertEqual(messages[6].data["lang"], "en-us") + self.assertFalse(messages[6].data["expect_response"]) + self.assertEqual(messages[6].data["meta"]["dialog"], "done") + self.assertEqual(messages[6].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[7].msg_type, "mycroft.scheduler.schedule_event") + self.assertEqual(messages[8].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[8].data["name"], "ScheduleSkill.handle_sched_intent") # ensure context in triggered event is the same from message that triggered the intent - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - intent_context = messages[4].context # when skill added to active list (last context change) + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + intent_context = messages[1].context # when skill added to active list (last context change) - self.assertEqual(messages[11].msg_type, "skill-ovos-schedule.openvoiceos:my_event") + self.assertEqual(messages[10].msg_type, "skill-ovos-schedule.openvoiceos:my_event") + self.assertEqual(messages[10].context, intent_context) + self.assertEqual(messages[11].msg_type, "enclosure.active_skill") self.assertEqual(messages[11].context, intent_context) - self.assertEqual(messages[12].msg_type, "enclosure.active_skill") + self.assertEqual(messages[12].msg_type, "speak") + self.assertEqual(messages[12].data["lang"], "en-us") + self.assertFalse(messages[12].data["expect_response"]) + self.assertEqual(messages[12].data["meta"]["dialog"], "trigger") + self.assertEqual(messages[12].data["meta"]["skill"], self.skill_id) self.assertEqual(messages[12].context, intent_context) - self.assertEqual(messages[13].msg_type, "speak") - self.assertEqual(messages[13].data["lang"], "en-us") - self.assertFalse(messages[13].data["expect_response"]) - self.assertEqual(messages[13].data["meta"]["dialog"], "trigger") - self.assertEqual(messages[13].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[13].context, intent_context) def tearDown(self) -> None: self.core.stop() diff --git a/test/end2end/session/test_session.py b/test/end2end/session/test_session.py index 33fa4db9f6d..14890d5606e 100644 --- a/test/end2end/session/test_session.py +++ b/test/end2end/session/test_session.py @@ -52,12 +52,10 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", # no session - f"{self.skill_id}:HelloWorldIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", + f"{self.skill_id}:HelloWorldIntent", + "mycroft.skill.handler.start", "enclosure.active_skill", "speak", "mycroft.skill.handler.complete", @@ -77,34 +75,21 @@ def wait_for_n_messages(n): self.assertEqual(m.context["session"]["session_id"], "default") self.assertEqual(m.context["lang"], "en-us") - # verify intent triggers - self.assertEqual(messages[1].msg_type, f"{self.skill_id}:HelloWorldIntent") - self.assertEqual(messages[1].data["intent_type"], f"{self.skill_id}:HelloWorldIntent") + # verify skill is activated + self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[1].data["skill_id"], self.skill_id) + self.assertEqual(messages[2].msg_type, f"{self.skill_id}.activate") # verify skill_id is now present in every message.context for m in messages[1:]: self.assertEqual(m.context["skill_id"], self.skill_id) - - # verify intent - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["name"], "HelloWorldSkill.handle_hello_world_intent") - # verify skill is activated - self.assertEqual(messages[3].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[3].data["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[4].data["skill_id"], self.skill_id) - self.assertEqual(messages[5].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[6].msg_type, "ovos.session.update_default") - # verify intent code execution - self.assertEqual(messages[7].msg_type, "enclosure.active_skill") - self.assertEqual(messages[7].data["skill_id"], self.skill_id) - self.assertEqual(messages[8].msg_type, "speak") - self.assertEqual(messages[8].data["lang"], "en-us") - self.assertFalse(messages[8].data["expect_response"]) - self.assertEqual(messages[8].data["meta"]["dialog"], "hello.world") - self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) + # verify intent triggers + self.assertEqual(messages[3].msg_type, f"{self.skill_id}:HelloWorldIntent") + self.assertEqual(messages[3].data["intent_type"], f"{self.skill_id}:HelloWorldIntent") + self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[4].data["name"], "HelloWorldSkill.handle_hello_world_intent") # intent complete - self.assertEqual(messages[9].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[9].data["name"], "HelloWorldSkill.handle_hello_world_intent") + self.assertEqual(messages[-3].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[-3].data["name"], "HelloWorldSkill.handle_hello_world_intent") # verify default session is now updated self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") @@ -159,12 +144,10 @@ def wait_for_n_messages(n): "recognizer_loop:utterance", f"{self.skill_id}.converse.ping", "skill.converse.pong", - f"{self.skill_id}:HelloWorldIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", - "ovos.session.update_default", + f"{self.skill_id}:HelloWorldIntent", + "mycroft.skill.handler.start", "enclosure.active_skill", "speak", "mycroft.skill.handler.complete", @@ -190,32 +173,22 @@ def wait_for_n_messages(n): self.assertEqual(messages[2].context["skill_id"], self.skill_id) self.assertFalse(messages[2].data["can_handle"]) + # verify skill is activated + self.assertEqual(messages[3].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[3].data["skill_id"], self.skill_id) + self.assertEqual(messages[4].msg_type, f"{self.skill_id}.activate") # verify intent triggers - self.assertEqual(messages[3].msg_type, f"{self.skill_id}:HelloWorldIntent") - self.assertEqual(messages[3].data["intent_type"], f"{self.skill_id}:HelloWorldIntent") + self.assertEqual(messages[5].msg_type, f"{self.skill_id}:HelloWorldIntent") + self.assertEqual(messages[5].data["intent_type"], f"{self.skill_id}:HelloWorldIntent") # verify skill_id is now present in every message.context for m in messages[3:]: self.assertEqual(m.context["skill_id"], self.skill_id) - self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") - # verify skill is activated - self.assertEqual(messages[5].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[5].data["skill_id"], self.skill_id) - self.assertEqual(messages[6].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[6].data["skill_id"], self.skill_id) - self.assertEqual(messages[7].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[8].msg_type, "ovos.session.update_default") - # verify intent code execution - self.assertEqual(messages[9].msg_type, "enclosure.active_skill") - self.assertEqual(messages[9].data["skill_id"], self.skill_id) - self.assertEqual(messages[10].msg_type, "speak") - self.assertEqual(messages[10].data["lang"], "en-us") - self.assertFalse(messages[10].data["expect_response"]) - self.assertEqual(messages[10].data["meta"]["dialog"], "hello.world") - self.assertEqual(messages[10].data["meta"]["skill"], self.skill_id) + self.assertEqual(messages[6].msg_type, "mycroft.skill.handler.start") + # intent complete - self.assertEqual(messages[11].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[11].data["name"], "HelloWorldSkill.handle_hello_world_intent") + self.assertEqual(messages[-3].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[-3].data["name"], "HelloWorldSkill.handle_hello_world_intent") # verify default session is now updated self.assertEqual(messages[-1].msg_type, "ovos.session.update_default") @@ -277,11 +250,10 @@ def wait_for_n_messages(n): "recognizer_loop:utterance", f"{self.skill_id}.converse.ping", "skill.converse.pong", - f"{self.skill_id}:HelloWorldIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", + f"{self.skill_id}:HelloWorldIntent", + "mycroft.skill.handler.start", "enclosure.active_skill", "speak", "mycroft.skill.handler.complete", @@ -305,33 +277,31 @@ def wait_for_n_messages(n): self.assertEqual(messages[2].data["skill_id"], self.skill_id) self.assertEqual(messages[2].context["skill_id"], self.skill_id) self.assertFalse(messages[2].data["can_handle"]) - + # verify skill is activated + self.assertEqual(messages[3].msg_type, "intent.service.skills.activated") + self.assertEqual(messages[3].data["skill_id"], self.skill_id) + self.assertEqual(messages[4].msg_type, f"{self.skill_id}.activate") # verify intent triggers - self.assertEqual(messages[3].msg_type, f"{self.skill_id}:HelloWorldIntent") - self.assertEqual(messages[3].data["intent_type"], f"{self.skill_id}:HelloWorldIntent") + self.assertEqual(messages[5].msg_type, f"{self.skill_id}:HelloWorldIntent") + self.assertEqual(messages[5].data["intent_type"], f"{self.skill_id}:HelloWorldIntent") # verify skill_id is now present in every message.context for m in messages[3:]: self.assertEqual(m.context["skill_id"], self.skill_id) # verify intent execution - self.assertEqual(messages[4].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[4].data["name"], "HelloWorldSkill.handle_hello_world_intent") - # verify skill is activated - self.assertEqual(messages[5].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[5].data["skill_id"], self.skill_id) - self.assertEqual(messages[6].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[6].data["skill_id"], self.skill_id) - self.assertEqual(messages[7].msg_type, f"{self.skill_id}.activate") - - self.assertEqual(messages[8].msg_type, "enclosure.active_skill") - self.assertEqual(messages[8].data["skill_id"], self.skill_id) - self.assertEqual(messages[9].msg_type, "speak") - self.assertEqual(messages[9].data["lang"], "en-us") - self.assertFalse(messages[9].data["expect_response"]) - self.assertEqual(messages[9].data["meta"]["dialog"], "hello.world") - self.assertEqual(messages[9].data["meta"]["skill"], self.skill_id) - self.assertEqual(messages[10].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[10].data["name"], "HelloWorldSkill.handle_hello_world_intent") + self.assertEqual(messages[6].msg_type, "mycroft.skill.handler.start") + self.assertEqual(messages[6].data["name"], "HelloWorldSkill.handle_hello_world_intent") + + self.assertEqual(messages[7].msg_type, "enclosure.active_skill") + self.assertEqual(messages[7].data["skill_id"], self.skill_id) + self.assertEqual(messages[8].msg_type, "speak") + self.assertEqual(messages[8].data["lang"], "en-us") + self.assertFalse(messages[8].data["expect_response"]) + self.assertEqual(messages[8].data["meta"]["dialog"], "hello.world") + self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) + + self.assertEqual(messages[-2].msg_type, "mycroft.skill.handler.complete") + self.assertEqual(messages[-2].data["name"], "HelloWorldSkill.handle_hello_world_intent") # test that active skills list has been updated sess = Session.from_message(messages[-1]) diff --git a/test/end2end/session/test_stop.py b/test/end2end/session/test_stop.py index f6836c2c257..ac94f3901e4 100644 --- a/test/end2end/session/test_stop.py +++ b/test/end2end/session/test_stop.py @@ -107,11 +107,10 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", # skill selected - f"{self.skill_id}:OldWorldIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.skill_id}.activate", + f"{self.skill_id}:OldWorldIntent", + "mycroft.skill.handler.start", # skill code executing "enclosure.active_skill", "speak", @@ -125,7 +124,7 @@ def wait_for_n_messages(n): self.assertEqual(m.msg_type, expected_messages[idx]) # sanity check correct intent triggered - self.assertEqual(messages[7].data["utterance"], "hello world") + self.assertEqual(messages[-3].data["utterance"], "hello world") # test that active skills list has been updated sess = Session.deserialize(messages[-1].context["session"]) @@ -281,11 +280,10 @@ def wait_for_n_messages(n): expected_messages = [ "recognizer_loop:utterance", # skill selected - f"{self.new_skill_id}:NewWorldIntent", - "mycroft.skill.handler.start", - "intent.service.skills.activate", "intent.service.skills.activated", f"{self.new_skill_id}.activate", + f"{self.new_skill_id}:NewWorldIntent", + "mycroft.skill.handler.start", # skill code executing "enclosure.active_skill", "speak",