diff --git a/mycroft/skills/intent_services/__init__.py b/mycroft/skills/intent_services/__init__.py index 8a0355a5d17..ddddfa3b49b 100644 --- a/mycroft/skills/intent_services/__init__.py +++ b/mycroft/skills/intent_services/__init__.py @@ -1,13 +1,13 @@ -from ovos_core.intent_services import AdaptService,\ - ConverseService, \ - CommonQAService, \ - FallbackService, \ - PadaciosoService -from ovos_core.intent_services import IntentMatch -from mycroft.skills.intent_services.adapt_service import AdaptIntent, IntentBuilder, Intent +from ovos_core.intent_services.fallback_service import FallbackService +from ovos_core.intent_services.converse_service import ConverseService +from ovos_adapt.opm import AdaptPipeline as AdaptService +from padacioso.opm import PadaciosoPipeline as PadaciosoService +from ovos_commonqa.opm import CommonQAService +from ovos_plugin_manager.templates.pipeline import IntentMatch +from ovos_workshop.intents import Intent as AdaptIntent, IntentBuilder, Intent try: - from ovos_core.intent_services.padatious_service import PadatiousService, PadatiousMatcher + from ovos_padatious.opm import PadatiousPipeline as PadatiousService, PadatiousMatcher except ImportError: from ovos_utils.log import LOG LOG.warning("padatious not installed") diff --git a/mycroft/skills/intent_services/adapt_service.py b/mycroft/skills/intent_services/adapt_service.py index fa8ac0881ab..447e1e3904c 100644 --- a/mycroft/skills/intent_services/adapt_service.py +++ b/mycroft/skills/intent_services/adapt_service.py @@ -13,10 +13,11 @@ # limitations under the License. # """An intent parsing service using the Adapt parser.""" -from ovos_adapt.context import ContextManagerFrame from ovos_adapt.engine import IntentDeterminationEngine from ovos_workshop.intents import IntentBuilder, Intent -from ovos_adapt.opm import ContextManager, AdaptPipeline as AdaptService +from ovos_adapt.opm import AdaptPipeline as AdaptService +from ovos_bus_client.session import IntentContextManagerFrame as ContextManagerFrame, \ + IntentContextManager as ContextManager class AdaptIntent(IntentBuilder): diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index 05d46e143d8..cea505d7fb5 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -12,26 +12,25 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from typing import Tuple, Callable +from typing import Tuple, Callable, Union +from ocp_pipeline.opm import OCPPipelineMatcher +from ovos_adapt.opm import AdaptPipeline as AdaptService from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager from ovos_bus_client.util import get_message_lang -from ovos_workshop.intents import open_intent_envelope - -from ocp_pipeline.opm import OCPPipelineMatcher -from ovos_adapt.opm import AdaptPipeline as AdaptService from ovos_commonqa.opm import CommonQAService from ovos_config.config import Configuration -from ovos_config.locale import setup_locale, get_valid_languages, get_full_lang_code +from ovos_config.locale import setup_locale, get_valid_languages from ovos_core.intent_services.converse_service import ConverseService from ovos_core.intent_services.fallback_service import FallbackService from ovos_core.intent_services.stop_service import StopService from ovos_core.transformers import MetadataTransformersService, UtteranceTransformersService -from ovos_plugin_manager.templates.pipeline import IntentMatch +from ovos_plugin_manager.templates.pipeline import PipelineMatch, IntentHandlerMatch from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG, deprecated, log_deprecation from ovos_utils.metrics import Stopwatch +from ovos_workshop.intents import open_intent_envelope from padacioso.opm import PadaciosoPipeline as PadaciosoService @@ -284,13 +283,14 @@ def disambiguate_lang(message): """ default_lang = get_message_lang(message) valid_langs = get_valid_languages() + valid_langs = [standardize_lang_tag(l) for l in valid_langs] lang_keys = ["stt_lang", "request_lang", "detected_lang"] for k in lang_keys: if k in message.context: - v = get_full_lang_code(message.context[k]) - if v in valid_langs: + v = standardize_lang_tag(message.context[k]) + if v in valid_langs: # TODO - use lang distance instead to choose best dialect if v != default_lang: LOG.info(f"replaced {default_lang} with {k}: {v}") return v @@ -314,8 +314,7 @@ def get_pipeline(self, skips=None, session=None) -> Tuple[str, Callable]: "intent matching will be extremely slow in comparison") padatious_matcher = self._padacioso_service else: - from ovos_core.intent_services.padatious_service import PadatiousMatcher - padatious_matcher = PadatiousMatcher(self._padatious_service) + padatious_matcher = self._padatious_service matchers = { "converse": self._converse.converse_with_skills, @@ -351,7 +350,8 @@ def get_pipeline(self, skips=None, session=None) -> Tuple[str, Callable]: LOG.debug(f"Session pipeline: {pipeline}") return [(k, matchers[k]) for k in pipeline] - def _validate_session(self, message, lang): + @staticmethod + def _validate_session(message, lang): # get session lang = standardize_lang_tag(lang) sess = SessionManager.get(message) @@ -373,12 +373,12 @@ def _validate_session(self, message, lang): sess.touch() return sess - def _emit_match_message(self, match: IntentMatch, message: Message): + def _emit_match_message(self, match: Union[IntentHandlerMatch, PipelineMatch], message: Message): """Update the message data with the matched utterance information and activate the corresponding skill if available. Args: - match (IntentMatch): The matched utterance object. + match (IntentHandlerMatch): The matched utterance object. message (Message): The messagebus data. """ message.data["utterance"] = match.utterance @@ -387,19 +387,19 @@ def _emit_match_message(self, match: IntentMatch, message: Message): # ensure skill_id is present in message.context message.context["skill_id"] = match.skill_id - if match.intent_type is True: + if isinstance(match, PipelineMatch) and match.handled: # utterance fully handled reply = message.reply("ovos.utterance.handled", {"skill_id": match.skill_id}) self.bus.emit(reply) # Launch skill if not handled by the match function - elif match.intent_type: + elif isinstance(match, IntentHandlerMatch) and match.match_type: # keep all original message.data and update with intent match data = dict(message.data) - data.update(match.intent_data) + data.update(match.match_data) # NOTE: message.reply to ensure correct message destination - reply = message.reply(match.intent_type, data) + reply = message.reply(match.match_type, data) # let's activate the skill BEFORE the intent is triggered # to ensure an accurate Session @@ -483,9 +483,9 @@ def handle_utterance(self, message: Message): LOG.debug( f"ignoring match, skill_id '{match.skill_id}' blacklisted by Session '{sess.session_id}'") continue - if match.intent_type and match.intent_type in sess.blacklisted_intents: + if isinstance(match, IntentHandlerMatch) and match.match_type in sess.blacklisted_intents: LOG.debug( - f"ignoring match, intent '{match.intent_type}' blacklisted by Session '{sess.session_id}'") + f"ignoring match, intent '{match.match_type}' blacklisted by Session '{sess.session_id}'") continue try: self._emit_match_message(match, message) @@ -529,7 +529,7 @@ def handle_register_vocab(self, message): alias_of = message.data.get('alias_of') lang = get_message_lang(message) self._adapt_service.register_vocabulary(entity_value, entity_type, - alias_of, regex_str, lang) + alias_of, regex_str, lang) self.registered_vocab.append(message.data) def handle_register_intent(self, message): @@ -559,7 +559,8 @@ def handle_detach_skill(self, message): skill_id = message.data.get('skill_id') self._adapt_service.detach_skill(skill_id) - def handle_add_context(self, message): + @staticmethod + def handle_add_context(message: Message): """Add context Args: @@ -581,7 +582,8 @@ def handle_add_context(self, message): sess = SessionManager.get(message) sess.context.inject_context(entity) - def handle_remove_context(self, message): + @staticmethod + def handle_remove_context(message: Message): """Remove specific context Args: @@ -592,7 +594,8 @@ def handle_remove_context(self, message): sess = SessionManager.get(message) sess.context.remove_context(context) - def handle_clear_context(self, message): + @staticmethod + def handle_clear_context(message: Message): """Clears all keywords from context """ sess = SessionManager.get(message) sess.context.clear_context() @@ -615,10 +618,10 @@ def handle_get_intent(self, message): session=sess): match = match_func([utterance], lang, message) if match: - if match.intent_type: - intent_data = match.intent_data - intent_data["intent_name"] = match.intent_type - intent_data["intent_service"] = match.intent_service + if match.match_type: + intent_data = match.match_data + intent_data["intent_name"] = match.match_type + intent_data["intent_service"] = pipeline intent_data["skill_id"] = match.skill_id intent_data["handler"] = match_func.__name__ self.bus.emit(message.reply("intent.service.intent.reply", @@ -657,7 +660,7 @@ def handle_get_adapt(self, message: Message): utterance = message.data["utterance"] lang = get_message_lang(message) intent = self._adapt_service.match_intent((utterance,), lang, message.serialize()) - intent_data = intent.intent_data if intent else None + intent_data = intent.match_data if intent else None self.bus.emit(message.reply("intent.service.adapt.reply", {"intent": intent_data})) diff --git a/ovos_core/intent_services/converse_service.py b/ovos_core/intent_services/converse_service.py index ace8b73725a..37a9d99ce29 100644 --- a/ovos_core/intent_services/converse_service.py +++ b/ovos_core/intent_services/converse_service.py @@ -5,14 +5,13 @@ from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager, UtteranceState, Session from ovos_bus_client.util import get_message_lang -from ovos_workshop.permissions import ConverseMode, ConverseActivationMode - from ovos_config.config import Configuration from ovos_config.locale import setup_locale -from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin +from ovos_plugin_manager.templates.pipeline import PipelineMatch, PipelinePlugin from ovos_utils import flatten_list from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG +from ovos_workshop.permissions import ConverseMode, ConverseActivationMode class ConverseService(PipelinePlugin): @@ -313,7 +312,7 @@ def converse(self, utterances: List[str], skill_id: str, lang: str, message: Mes f'increasing "max_skill_runtime" in mycroft.conf might help alleviate this issue') return False - def converse_with_skills(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: + def converse_with_skills(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """Give active skills a chance at the utterance Args: @@ -338,12 +337,11 @@ def converse_with_skills(self, utterances: List[str], lang: str, message: Messag continue if self.converse(utterances, skill_id, lang, message): state = session.utterance_states.get(skill_id, UtteranceState.INTENT) - return IntentMatch(intent_service='Converse', - intent_type=state != UtteranceState.RESPONSE, - # intent_type == True -> emit "ovos.utterance.handled" - intent_data={}, - skill_id=skill_id, - utterance=utterances[0]) + return PipelineMatch(handled=state != UtteranceState.RESPONSE, + # handled == True -> emit "ovos.utterance.handled" + match_data={}, + skill_id=skill_id, + utterance=utterances[0]) return None @staticmethod diff --git a/ovos_core/intent_services/fallback_service.py b/ovos_core/intent_services/fallback_service.py index b4374a56b7e..df2d5cb042f 100644 --- a/ovos_core/intent_services/fallback_service.py +++ b/ovos_core/intent_services/fallback_service.py @@ -20,13 +20,12 @@ from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager -from ovos_workshop.permissions import FallbackMode - from ovos_config import Configuration -from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin +from ovos_plugin_manager.templates.pipeline import PipelineMatch, PipelinePlugin from ovos_utils import flatten_list from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG +from ovos_workshop.permissions import FallbackMode FallbackRange = namedtuple('FallbackRange', ['start', 'stop']) @@ -166,7 +165,7 @@ def attempt_fallback(self, utterances: List[str], skill_id: str, lang: str, mess return False def _fallback_range(self, utterances: List[str], lang: str, - message: Message, fb_range: FallbackRange) -> Optional[IntentMatch]: + message: Message, fb_range: FallbackRange) -> Optional[PipelineMatch]: """Send fallback request for a specified priority range. Args: @@ -177,7 +176,7 @@ def _fallback_range(self, utterances: List[str], lang: str, fb_range (FallbackRange): fallback order start and stop. Returns: - IntentMatch or None + PipelineMatch or None """ lang = standardize_lang_tag(lang) # we call flatten in case someone is sending the old style list of tuples @@ -197,24 +196,23 @@ def _fallback_range(self, utterances: List[str], lang: str, continue result = self.attempt_fallback(utterances, skill_id, lang, message) if result: - return IntentMatch(intent_service='Fallback', - intent_type=None, - intent_data={}, - skill_id=skill_id, - utterance=utterances[0]) + return PipelineMatch(handled=True, + match_data={}, + skill_id=skill_id, + utterance=utterances[0]) return None - def high_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: + def high_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """Pre-padatious fallbacks.""" return self._fallback_range(utterances, lang, message, FallbackRange(0, 5)) - def medium_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: + def medium_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """General fallbacks.""" return self._fallback_range(utterances, lang, message, FallbackRange(5, 90)) - def low_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: + def low_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """Low prio fallbacks with general matching such as chat-bot.""" return self._fallback_range(utterances, lang, message, FallbackRange(90, 101)) diff --git a/ovos_core/intent_services/stop_service.py b/ovos_core/intent_services/stop_service.py index bdb1137a75f..f9ba7f17b0b 100644 --- a/ovos_core/intent_services/stop_service.py +++ b/ovos_core/intent_services/stop_service.py @@ -5,11 +5,11 @@ from typing import Optional, List from langcodes import closest_match + from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager - from ovos_config.config import Configuration -from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin +from ovos_plugin_manager.templates.pipeline import PipelineMatch, PipelinePlugin from ovos_utils import flatten_list from ovos_utils.bracket_expansion import expand_options from ovos_utils.lang import standardize_lang_tag @@ -113,7 +113,7 @@ def stop_skill(self, skill_id: str, message: Message) -> bool: elif result is not None: return result.data.get('result', False) - def match_stop_high(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: + def match_stop_high(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """If utterance is an exact match for "stop" , run before intent stage Args: @@ -122,7 +122,7 @@ def match_stop_high(self, utterances: List[str], lang: str, message: Message) -> message (Message): message to use to generate reply Returns: - IntentMatch if handled otherwise None. + PipelineMatch if handled otherwise None. """ lang = self._get_closest_lang(lang) if lang is None: # no vocs registered for this lang @@ -142,11 +142,10 @@ def match_stop_high(self, utterances: List[str], lang: str, message: Message) -> if is_global_stop: # emit a global stop, full stop anything OVOS is doing self.bus.emit(message.reply("mycroft.stop", {})) - return IntentMatch(intent_service='Stop', - intent_type=True, - intent_data={"conf": conf}, - skill_id=None, - utterance=utterance) + return PipelineMatch(handled=True, + match_data={"conf": conf}, + skill_id=None, + utterance=utterance) if is_stop: # check if any skill can stop @@ -156,14 +155,13 @@ def match_stop_high(self, utterances: List[str], lang: str, message: Message) -> continue if self.stop_skill(skill_id, message): - return IntentMatch(intent_service='Stop', - intent_type=True, - intent_data={"conf": conf}, - skill_id=skill_id, - utterance=utterance) + return PipelineMatch(handled=True, + match_data={"conf": conf}, + skill_id=skill_id, + utterance=utterance) return None - def match_stop_medium(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: + def match_stop_medium(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """ if "stop" intent is in the utterance, but it contains additional words not in .intent files @@ -173,7 +171,7 @@ def match_stop_medium(self, utterances: List[str], lang: str, message: Message) message (Message): message to use to generate reply Returns: - IntentMatch if handled otherwise None. + PipelineMatch if handled otherwise None. """ lang = self._get_closest_lang(lang) if lang is None: # no vocs registered for this lang @@ -203,7 +201,7 @@ def _get_closest_lang(self, lang: str) -> Optional[str]: return closest return None - def match_stop_low(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: + def match_stop_low(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """ before fallback_low , fuzzy match stop intent Args: @@ -212,7 +210,7 @@ def match_stop_low(self, utterances: List[str], lang: str, message: Message) -> message (Message): message to use to generate reply Returns: - IntentMatch if handled otherwise None. + PipelineMatch if handled otherwise None. """ lang = self._get_closest_lang(lang) if lang is None: # no vocs registered for this lang @@ -236,20 +234,18 @@ def match_stop_low(self, utterances: List[str], lang: str, message: Message) -> continue if self.stop_skill(skill_id, message): - return IntentMatch(intent_service='Stop', - intent_type=True, - # emit instead of intent message - intent_data={"conf": conf}, - skill_id=skill_id, utterance=utterance) + return PipelineMatch(handled=True, + # emit instead of intent message + match_data={"conf": conf}, + skill_id=skill_id, utterance=utterance) # emit a global stop, full stop anything OVOS is doing self.bus.emit(message.reply("mycroft.stop", {})) - return IntentMatch(intent_service='Stop', - intent_type=True, - # emit instead of intent message {"conf": conf}, - intent_data={}, - skill_id=None, - utterance=utterance) + return PipelineMatch(handled=True, + # emit instead of intent message {"conf": conf}, + match_data={"conf": conf}, + skill_id=None, + utterance=utterance) def voc_match(self, utt: str, voc_filename: str, lang: str, exact: bool = False): diff --git a/requirements/lgpl.txt b/requirements/lgpl.txt index e92ee3c4a82..021af4313e6 100644 --- a/requirements/lgpl.txt +++ b/requirements/lgpl.txt @@ -1,2 +1,2 @@ -ovos_padatious>=0.1.3,<1.0.0 +ovos_padatious>=1.0.2, <2.0.0 fann2>=1.0.7, < 1.1.0 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 14d54b1f630..4c3a6417912 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -3,14 +3,14 @@ python-dateutil>=2.6, <3.0 watchdog>=2.1, <3.0 combo-lock>=0.2.2, <0.3 -padacioso>=0.2.4,<1.0.0 -ovos-adapt-parser>=0.1.3, <1.0.0 -ovos_ocp_pipeline_plugin>=0.1.3, <1.0.0 -ovos-common-query-pipeline-plugin>=0.1.4, <1.0.0 +padacioso>=1.0.0, <2.0.0 +ovos-adapt-parser>=1.0.2, <2.0.0 +ovos_ocp_pipeline_plugin>=1.0.1, <2.0.0 +ovos-common-query-pipeline-plugin>=1.0.0, <2.0.0 ovos-utils>=0.3.5,<1.0.0 ovos_bus_client>=0.1.4,<1.0.0 -ovos-plugin-manager>=0.0.26,<1.0.0 +ovos-plugin-manager>=0.5.0,<1.0.0 ovos-config>=0.0.13,<1.0.0 ovos-lingua-franca>=0.4.7,<1.0.0 ovos-backend-client>=0.1.0,<2.0.0 diff --git a/test/unittests/test_intent_service.py b/test/unittests/test_intent_service.py index bef2a35143c..0b5ac71524a 100644 --- a/test/unittests/test_intent_service.py +++ b/test/unittests/test_intent_service.py @@ -15,11 +15,12 @@ from unittest import TestCase, mock from ovos_bus_client.message import Message +from ovos_bus_client.session import IntentContextManager as ContextManager from ovos_bus_client.util import get_message_lang from ovos_config import Configuration from ovos_config.locale import setup_locale from ovos_core.intent_services import IntentService -from ovos_adapt.opm import ContextManager +from ovos_utils.fakebus import FakeBus from ovos_workshop.intents import IntentBuilder, Intent as AdaptIntent from copy import deepcopy from ovos_config import LocalConf, DEFAULT_CONFIG @@ -128,15 +129,17 @@ def create_vocab_msg(keyword, value): {'entity_value': value, 'entity_type': keyword}) -def get_last_message(bus): - """Get last sent message on mock bus.""" - last = bus.emit.call_args - return last[0][0] - - class TestIntentServiceApi(TestCase): def setUp(self): - self.intent_service = IntentService(mock.Mock()) + self.bus = FakeBus() + self.bus.emitted_msgs = [] + + def on_msg(m): + self.bus.emitted_msgs.append(Message.deserialize(m)) + + self.bus.on("message", on_msg) + + self.intent_service = IntentService(self.bus) def setup_simple_adapt_intent(self, msg=create_vocab_msg('testKeyword', 'test')): @@ -153,7 +156,7 @@ def test_get_adapt_intent(self): data={'utterance': 'test'}) self.intent_service.handle_get_adapt(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intent']['intent_type'], 'skill:testIntent') @@ -164,7 +167,7 @@ def test_get_adapt_intent_no_match(self): msg = Message('intent.service.adapt.get', data={'utterance': 'five'}) self.intent_service.handle_get_adapt(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intent'], None) def test_get_intent(self): @@ -175,7 +178,7 @@ def test_get_intent(self): data={'utterance': 'test'}) self.intent_service.handle_get_intent(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intent']['intent_type'], 'skill:testIntent') @@ -186,7 +189,7 @@ def test_get_intent_no_match(self): msg = Message('intent.service.intent.get', data={'utterance': 'five'}) self.intent_service.handle_get_intent(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intent'], None) def test_get_intent_manifest(self): @@ -196,7 +199,7 @@ def test_get_intent_manifest(self): msg = Message('intent.service.intent.get', data={'utterance': 'five'}) self.intent_service.handle_get_intent(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intent'], None) def test_get_adapt_intent_manifest(self): @@ -204,7 +207,7 @@ def test_get_adapt_intent_manifest(self): self.setup_simple_adapt_intent() msg = Message('intent.service.adapt.manifest.get') self.intent_service.handle_adapt_manifest(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intents'][0]['name'], 'skill:testIntent') @@ -212,7 +215,7 @@ def test_get_adapt_vocab_manifest(self): self.setup_simple_adapt_intent() msg = Message('intent.service.adapt.vocab.manifest.get') self.intent_service.handle_vocab_manifest(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] value = reply.data['vocab'][0]['entity_value'] keyword = reply.data['vocab'][0]['entity_type'] self.assertEqual(keyword, 'testKeyword') @@ -227,7 +230,7 @@ def test_get_no_match_after_detach(self): self.intent_service.handle_detach_intent(msg) msg = Message('intent.service.adapt.get', data={'utterance': 'test'}) self.intent_service.handle_get_adapt(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intent'], None) def test_get_no_match_after_detach_skill(self): @@ -239,94 +242,9 @@ def test_get_no_match_after_detach_skill(self): self.intent_service.handle_detach_skill(msg) msg = Message('intent.service.adapt.get', data={'utterance': 'test'}) self.intent_service.handle_get_adapt(msg) - reply = get_last_message(self.intent_service.bus) + reply = self.bus.emitted_msgs[-1] self.assertEqual(reply.data['intent'], None) - def test_shutdown(self): - intent_service = IntentService(MockEmitter(), config={"padatious": {"disabled": True}}) - intent_service.shutdown() - self.assertEqual(set(intent_service.bus.removed), - {'active_skill_request', - 'add_context', - 'clear_context', - 'common_query.openvoiceos.activate', - 'common_query.openvoiceos.converse.get_response', - 'common_query.openvoiceos.converse.ping', - 'common_query.openvoiceos.converse.request', - 'common_query.openvoiceos.deactivate', - 'common_query.openvoiceos.set', - 'common_query.openvoiceos.stop', - 'common_query.openvoiceos.stop.ping', - 'common_query.question', - 'detach_intent', - 'detach_skill', - 'intent.service.active_skills.get', - 'intent.service.adapt.get', - 'intent.service.adapt.manifest.get', - 'intent.service.adapt.vocab.manifest.get', - 'intent.service.intent.get', - 'intent.service.padatious.entities.manifest.get', - 'intent.service.padatious.get', - 'intent.service.padatious.manifest.get', - 'intent.service.skills.activate', - 'intent.service.skills.activated', - 'intent.service.skills.deactivate', - 'intent.service.skills.deactivated', - 'intent.service.skills.get', - 'mycroft.audio.playing_track', - 'mycroft.audio.queue_end', - 'mycroft.audio.service.pause', - 'mycroft.audio.service.resume', - 'mycroft.audio.service.stop', - 'mycroft.skill.disable_intent', - 'mycroft.skill.enable_intent', - 'mycroft.skill.remove_cross_context', - 'mycroft.skill.set_cross_context', - 'mycroft.skills.loaded', - 'mycroft.skills.settings.changed', - 'mycroft.speech.recognition.unknown', - 'mycroft.stop', - 'ocp:legacy_cps', - 'ocp:like_song', - 'ocp:media_stop', - 'ocp:next', - 'ocp:open', - 'ocp:pause', - 'ocp:play', - 'ocp:play_favorites', - 'ocp:prev', - 'ocp:resume', - 'ocp:search_error', - 'ovos.common_play.activate', - 'ovos.common_play.announce', - 'ovos.common_play.converse.get_response', - 'ovos.common_play.converse.ping', - 'ovos.common_play.converse.request', - 'ovos.common_play.deactivate', - 'ovos.common_play.deregister_keyword', - 'ovos.common_play.play_search', - 'ovos.common_play.register_keyword', - 'ovos.common_play.search', - 'ovos.common_play.set', - 'ovos.common_play.status.response', - 'ovos.common_play.stop', - 'ovos.common_play.stop.ping', - 'ovos.common_play.track.state', - 'ovos.common_query.pong', - 'ovos.skills.fallback.deregister', - 'ovos.skills.fallback.register', - 'ovos.skills.settings_changed', - 'padatious:register_entity', - 'padatious:register_intent', - 'play:query.response', - 'question:query.response', - 'recognizer_loop:utterance', - 'register_intent', - 'register_vocab', - 'remove_context', - 'skill.converse.get_response.disable', - 'skill.converse.get_response.enable'}) - class TestAdaptIntent(TestCase): """Test the AdaptIntent wrapper."""