Remove broken auto-naming of resting_screen_handler

The automatic naming of the resting_screen_handler wasn't working (error
occured if no name was supplied)

Added test case for the function
pull/2185/head
Åke Forslund 2019-07-03 08:38:17 +02:00
parent 63c3737f98
commit fbcf731556
2 changed files with 17 additions and 4 deletions

View File

@ -460,13 +460,11 @@ class SkillGUI:
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.
If selected will be shown on screen when device enters idle mode
"""
name = name or func.__self__.name
def real_decorator(func):
# Store the resting information inside the function
# 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, \
load_vocab_from_file, load_vocabulary
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
@ -56,6 +56,21 @@ class MockEmitter(object):
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):
emitter = MockEmitter()
regex_path = abspath(join(dirname(__file__), '../regex_test'))