Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run UnitTests
on:
pull_request:
branches:
- dev
- master
push:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop this and just run on PR personally

workflow_dispatch:

jobs:
unit_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Build Tools
run: |
python -m pip install build wheel
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt install python3-dev swig libssl-dev libfann-dev portaudio19-dev libpulse-dev
- name: Install core repo
run: |
pip install .[audio-backend,mark1,stt,tts,skills,gui,bus,PHAL,all]
- name: Install test dependencies
run: |
pip install pytest pytest-timeout pytest-cov
- name: Run unittests
run: |
pytest test/unittests
2 changes: 1 addition & 1 deletion mycroft/skills/intent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(self, bus):
@property
def registered_intents(self):
return [parser.__dict__
for parser in self.adapt_service.engine.intent_parsers]
for parser in self.adapt_service.engines["en-us"].intent_parsers]

def update_skill_name_dict(self, message):
"""Messagebus handler, updates dict of id to skill name conversions."""
Expand Down
95 changes: 0 additions & 95 deletions test/unittests/audio/test_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,101 +60,6 @@ def test_life_cycle(self, tts_factory_mock, config_mock):
self.assertTrue(tts_mock.playback.stop.called)
self.assertTrue(tts_mock.playback.join.called)

def test_speak(self, tts_factory_mock, config_mock):
"""Ensure the speech handler executes the tts."""
setup_mocks(config_mock, tts_factory_mock)
bus = mock.Mock()
speech.init(bus)

speak_msg = Message('speak',
data={'utterance': 'hello there. world',
'listen': False},
context={'ident': 'a'})
speech.handle_speak(speak_msg)
tts_mock.execute.assert_has_calls(
[mock.call('hello there.', 'a', False),
mock.call('world', 'a', False)])

@mock.patch('mycroft.audio.speech.Mimic')
def test_fallback_tts(self, mimic_cls_mock, tts_factory_mock, config_mock):
"""Ensure the fallback tts is triggered if the remote times out."""
setup_mocks(config_mock, tts_factory_mock)
mimic_mock = mock.Mock()
mimic_cls_mock.return_value = mimic_mock

tts = tts_factory_mock.create.return_value
tts.execute.side_effect = RemoteTTSTimeoutException

bus = mock.Mock()
speech.init(bus)

speak_msg = Message('speak',
data={'utterance': 'hello there. world',
'listen': False},
context={'ident': 'a'})
speech.handle_speak(speak_msg)
mimic_mock.execute.assert_has_calls(
[mock.call('hello there.', 'a', False),
mock.call('world', 'a', False)])

@mock.patch('mycroft.audio.speech.check_for_signal')
def test_abort_speak(self, check_for_signal_mock, tts_factory_mock,
config_mock):
"""Ensure the speech handler aborting speech on stop signal."""
setup_mocks(config_mock, tts_factory_mock)
check_for_signal_mock.return_value = True
tts = tts_factory_mock.create.return_value

def execute_trigger_stop():
speech.handle_stop(None)

tts.execute.side_effect = execute_trigger_stop

bus = mock.Mock()
speech.init(bus)

speak_msg = Message('speak',
data={'utterance': 'hello there. world',
'listen': False},
context={'ident': 'a'})
speech.handle_speak(speak_msg)
self.assertTrue(tts.playback.clear.called)

def test_speak_picroft(self, tts_factory_mock, config_mock):
"""Ensure that picroft doesn't split the sentence."""
setup_mocks(config_mock, tts_factory_mock)
bus = mock.Mock()
config_mock.get.return_value = {'enclosure': {'platform': 'picroft'}}
speech.init(bus)

speak_msg = Message('speak',
data={'utterance': 'hello there. world',
'listen': False},
context={'ident': 'a'})
speech.handle_speak(speak_msg)
tts_mock.execute.assert_has_calls(
[mock.call('hello there. world', 'a', False)])

config_mock.get.return_value = {}

def test_speak_update_tts(self, tts_factory_mock, config_mock):
"""Verify that a new config triggers reload of tts."""
setup_mocks(config_mock, tts_factory_mock)
bus = mock.Mock()
config_mock.get.return_value = {'tts': {'module': 'test'}}
speech.init(bus)
tts_factory_mock.create.reset_mock()
speak_msg = Message('speak',
data={'utterance': 'hello there. world',
'listen': False},
context={'ident': 'a'})
speech.handle_speak(speak_msg)
self.assertFalse(tts_factory_mock.create.called)

speech.config = {'tts': {'module': 'test2'}}
speech.handle_speak(speak_msg)
self.assertTrue(tts_factory_mock.create.called)

@mock.patch('mycroft.audio.speech.check_for_signal')
def test_stop(self, check_for_signal_mock, tts_factory_mock, config_mock):
"""Ensure the stop handler signals stop correctly."""
Expand Down
75 changes: 0 additions & 75 deletions test/unittests/audio/test_vlc_backend.py

This file was deleted.

Loading