Merge pull request #2767 from forslund/bugfix/anonymous-AdaptIntent

Bugfix/anonymous adapt intent
pull/2762/head
Kris Gesling 2020-12-01 21:55:07 +09:30 committed by GitHub
commit da280e360c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -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):

View File

@ -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, "")