Merge pull request #2185 from forslund/bugfix/resting-screen-handler

Resting screen handler name fix
pull/2190/head
Åke 2019-07-04 18:03:48 +02:00 committed by GitHub
commit fa23815f96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -460,13 +460,11 @@ class SkillGUI:
self.show_page("SYSTEM_UrlFrame.qml", override_idle) self.show_page("SYSTEM_UrlFrame.qml", override_idle)
def resting_screen_handler(name=None): def resting_screen_handler(name):
""" Decorator for adding a method as an resting screen handler. """ Decorator for adding a method as an resting screen handler.
If selected will be shown on screen when device enters idle mode If selected will be shown on screen when device enters idle mode
""" """
name = name or func.__self__.name
def real_decorator(func): def real_decorator(func):
# Store the resting information inside the function # Store the resting information inside the function
# This will be used later in register_resting_screen # This will be used later in register_resting_screen

View File

@ -27,7 +27,7 @@ from mycroft.messagebus.message import Message
from mycroft.skills.skill_data import load_regex_from_file, load_regex, \ from mycroft.skills.skill_data import load_regex_from_file, load_regex, \
load_vocab_from_file, load_vocabulary load_vocab_from_file, load_vocabulary
from mycroft.skills.core import MycroftSkill, load_skill, \ from mycroft.skills.core import MycroftSkill, load_skill, \
create_skill_descriptor, open_intent_envelope create_skill_descriptor, open_intent_envelope, resting_screen_handler
from test.util import base_config from test.util import base_config
@ -56,6 +56,21 @@ class MockEmitter(object):
self.results = [] self.results = []
class FunctionTest(unittest.TestCase):
def test_resting_screen_handler(self):
class T(MycroftSkill):
def __init__(self):
self.name = 'TestObject'
@resting_screen_handler('humbug')
def f(self):
pass
test_class = T()
self.assertTrue('resting_handler' in dir(test_class.f))
self.assertEquals(test_class.f.resting_handler, 'humbug')
class MycroftSkillTest(unittest.TestCase): class MycroftSkillTest(unittest.TestCase):
emitter = MockEmitter() emitter = MockEmitter()
regex_path = abspath(join(dirname(__file__), '../regex_test')) regex_path = abspath(join(dirname(__file__), '../regex_test'))
@ -350,6 +365,8 @@ class MycroftSkillTest(unittest.TestCase):
'name': str(s.skill_id) + ':test.intent'}] 'name': str(s.skill_id) + ':test.intent'}]
self.check_register_decorators(expected) self.check_register_decorators(expected)
# Restore sys.path
sys.path = path_orig
def test_failing_set_context(self): def test_failing_set_context(self):
s = SimpleSkill1() s = SimpleSkill1()