Skip to content

Commit

Permalink
Implement tests for CLI module (#165)
Browse files Browse the repository at this point in the history
# Description
Add CLI module unit tests

# Issues
<!-- If this is related to or closes an issue/other PR, please note them
here -->

# Other Notes
<!-- Note any breaking changes, WIP changes, requests for input, etc.
here -->
  • Loading branch information
NeonDaniel authored Jun 3, 2023
1 parent 55af151 commit 23f6f51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion neon_speech/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from click_default_group import DefaultGroup
from neon_utils.packaging_utils import get_package_version_spec
from neon_utils.configuration_utils import init_config_dir


@click.group("neon-speech", cls=DefaultGroup,
Expand All @@ -52,7 +53,6 @@ def neon_speech_cli(version: bool = False):
@click.option("--force-install", "-f", default=False, is_flag=True,
help="Force pip installation of configured module")
def run(module, package, force_install):
from neon_utils.configuration_utils import init_config_dir
init_config_dir()

from neon_speech.__main__ import main
Expand Down
15 changes: 14 additions & 1 deletion tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

from os.path import dirname, join
from threading import Thread, Event
from time import sleep
from unittest.mock import Mock, patch
from click.testing import CliRunner

from ovos_bus_client import Message
from ovos_dinkum_listener.voice_loop.hotwords import HotWordException
Expand Down Expand Up @@ -451,5 +452,17 @@ def test_reload_hotwords(self):
.get('engine'))


class TestCLI(unittest.TestCase):
runner = CliRunner()

@patch("neon_speech.cli.init_config_dir")
@patch("neon_speech.__main__.main")
def test_run(self, main, init_config):
from neon_speech.cli import run
self.runner.invoke(run)
init_config.assert_called_once()
main.assert_called_once()


if __name__ == '__main__':
unittest.main()

0 comments on commit 23f6f51

Please sign in to comment.