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

Commit 287550d

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

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/unittests/skills/test_common_query_skill.py

+10-2
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,10 @@ 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):
96-
self.skill.config_core['enclosure']['platform'] = 'mycroft_mark_2'
97+
self.skill.gui.connected = True
9798
query_phrase = self.bus.on.call_args_list[-2][0][1]
9899
self.skill.CQS_match_query_phrase.return_value = (
99100
'What\'s the meaning of life', CQSVisualMatchLevel.EXACT, '42')
100-
101101
query_phrase(Message('question:query',
102102
data={'phrase': 'What\'s the meaning of life'}))
103103

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

120120
class CQSTest(CommonQuerySkill):
121121
"""Simple skill for testing the CommonQuerySkill"""
122+
122123
def __init__(self, *args, **kwargs):
123124
super().__init__(*args, **kwargs)
124125
self.CQS_match_query_phrase = mock.Mock(name='match_phrase')
125126
self.CQS_action = mock.Mock(name='selected_action')
126127
self.skill_id = 'CQSTest'
128+
self.gui = MockGUI()
127129

128130
def CQS_match_query_phrase(self, phrase):
129131
pass
130132

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

0 commit comments

Comments
 (0)