From eb78d67ff7835001539814410c52b0b78b277f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Tue, 24 Nov 2020 10:49:04 +0100 Subject: [PATCH 1/2] Fix AdaptIntent without name. --- mycroft/skills/intent_services/adapt_service.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mycroft/skills/intent_services/adapt_service.py b/mycroft/skills/intent_services/adapt_service.py index 304d04138c..be69bd9a08 100644 --- a/mycroft/skills/intent_services/adapt_service.py +++ b/mycroft/skills/intent_services/adapt_service.py @@ -26,9 +26,11 @@ from .base import IntentMatch class AdaptIntent(IntentBuilder): """Wrapper for IntentBuilder setting a blank name. - This is mainly here for backwards compatibility, adapt now support - automatically named IntentBulders. + Arguments: + name (str): Optional name of intent """ + def __init__(self, name=''): + super().__init__(name) def _strip_result(context_features): From 21425da5430cd29b31407f99371f60a9c3aa87b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Tue, 24 Nov 2020 11:02:52 +0100 Subject: [PATCH 2/2] Add test for anonymous AdaptIntent --- test/unittests/skills/test_intent_service.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/unittests/skills/test_intent_service.py b/test/unittests/skills/test_intent_service.py index 02b8c6c053..fe30b97e5d 100644 --- a/test/unittests/skills/test_intent_service.py +++ b/test/unittests/skills/test_intent_service.py @@ -19,7 +19,7 @@ from adapt.intent import IntentBuilder from mycroft.configuration import Configuration from mycroft.messagebus import Message from mycroft.skills.intent_service import (ContextManager, IntentService, - _get_message_lang) + _get_message_lang, AdaptIntent) from test.util import base_config @@ -327,3 +327,14 @@ class TestIntentServiceApi(TestCase): self.intent_service.handle_get_adapt(msg) reply = get_last_message(self.intent_service.bus) self.assertEqual(reply.data['intent'], None) + + +class TestAdaptIntent(TestCase): + """Test the AdaptIntent wrapper.""" + def test_named_intent(self): + intent = AdaptIntent("CallEaglesIntent") + self.assertEqual(intent.name, "CallEaglesIntent") + + def test_unnamed_intent(self): + intent = AdaptIntent() + self.assertEqual(intent.name, "")