Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Commit cdcf1a0

Browse files
committed
Create a mock GUI with a settable connected attribute
1 parent 901dbd3 commit cdcf1a0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/unittests/skills/test_common_query_skill.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_common_test_skill_action(self):
3838

3939
class TestCommonQueryMatching(TestCase):
4040
"""Tests for CQS_match_query_phrase."""
41+
4142
def setUp(self):
4243
self.skill = CQSTest()
4344
self.bus = mock.Mock(name='bus')
@@ -93,11 +94,11 @@ def test_successful_match_query_phrase(self):
9394
self.assertEqual(response.data['conf'], 1.12)
9495

9596
def test_successful_visual_match_query_phrase(self):
97+
self.skill.gui.connected = True
9698
self.skill.config_core['enclosure']['platform'] = 'mycroft_mark_2'
9799
query_phrase = self.bus.on.call_args_list[-2][0][1]
98100
self.skill.CQS_match_query_phrase.return_value = (
99101
'What\'s the meaning of life', CQSVisualMatchLevel.EXACT, '42')
100-
101102
query_phrase(Message('question:query',
102103
data={'phrase': 'What\'s the meaning of life'}))
103104

@@ -119,14 +120,22 @@ def test_successful_visual_match_query_phrase(self):
119120

120121
class CQSTest(CommonQuerySkill):
121122
"""Simple skill for testing the CommonQuerySkill"""
123+
122124
def __init__(self, *args, **kwargs):
123125
super().__init__(*args, **kwargs)
124126
self.CQS_match_query_phrase = mock.Mock(name='match_phrase')
125127
self.CQS_action = mock.Mock(name='selected_action')
126128
self.skill_id = 'CQSTest'
129+
self.gui = MockGUI()
127130

128131
def CQS_match_query_phrase(self, phrase):
129132
pass
130133

131134
def CQS_action(self, phrase, data):
132135
pass
136+
137+
138+
class MockGUI():
139+
def __init__(self):
140+
self.connected = False
141+
self.setup_default_handlers = AnyCallable

0 commit comments

Comments
 (0)