diff --git a/__init__.py b/__init__.py index 6c021329..9baa6ebd 100644 --- a/__init__.py +++ b/__init__.py @@ -982,6 +982,11 @@ def _alert_expired(self, alert: Alert): :param alert: expired Alert object """ LOG.info(f'alert expired: {get_alert_id(alert)}') + # TODO: Emit generic event for remote clients + self.bus.emit(Message("neon.alert", alert.data, alert.context)) + if alert.context.get("mq"): + LOG.warning("Alert from remote client; do nothing locally") + return self.make_active() self._gui_notify_expired(alert) @@ -1043,6 +1048,7 @@ def _play_notify_expired(self, alert: Alert): while self.alert_manager.get_alert_status(alert_id) == \ AlertState.ACTIVE and time.time() < timeout: if alert_message.context.get("klat_data"): + # TODO: Deprecated self.send_with_audio(self.dialog_renderer.render( "expired_alert", {'name': alert.alert_name}), to_play, alert_message, private=True) @@ -1072,9 +1078,11 @@ def _speak_notify_expired(self, alert: Alert): if alert.alert_type == AlertType.REMINDER: self.speak_dialog('expired_reminder', {'name': alert.alert_name}, + message=alert_message, private=True, wait=True) else: self.speak_dialog('expired_alert', {'name': alert.alert_name}, + message=alert_message, private=True, wait=True) self.make_active() time.sleep(10) diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 00000000..55bb597d --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1 @@ +neon-minerva[padatious]~=0.1,>=0.1.1a5 diff --git a/setup.py b/setup.py index 88f480c7..1236fe9e 100644 --- a/setup.py +++ b/setup.py @@ -89,6 +89,7 @@ def find_resource_files(): url=f'https://github.com/NeonGeckoCom/{SKILL_NAME}', license='BSD-3-Clause', install_requires=get_requirements("requirements.txt"), + extras_require={"test": get_requirements("requirements/test.txt")}, author='Neongecko', author_email='developers@neon.ai', long_description=long_description, diff --git a/test/test_skill.py b/test/test_skill.py index 3bfd9164..2091b41e 100644 --- a/test/test_skill.py +++ b/test/test_skill.py @@ -16,11 +16,11 @@ # Specialized conversational reconveyance options from Conversation Processing Intelligence Corp. # US Patents 2008-2021: US7424516, US20140161250, US20140177813, US8638908, US8068604, US8553852, US10530923, US10530924 # China Patent: CN102017585 - Europe Patent: EU2156652 - Patents Pending + import datetime import json import os import time - import lingua_franca import pytest import random @@ -30,8 +30,8 @@ import datetime as dt from threading import Event -from os import mkdir, remove -from os.path import dirname, join, exists, isfile +from os import remove +from os.path import dirname, join, isfile from dateutil.tz import gettz from lingua_franca.format import nice_date_time, nice_duration from mock import Mock @@ -40,8 +40,9 @@ from ovos_utils.events import EventSchedulerInterface from ovos_utils.messagebus import FakeBus from lingua_franca import load_language +from lingua_franca.format import nice_time -from mycroft.util.format import nice_time +from neon_minerva.tests.skill_unit_test_base import SkillTestCase sys.path.append(dirname(dirname(__file__))) from util import AlertType, AlertState, AlertPriority, Weekdays, EVERYDAY @@ -57,27 +58,10 @@ def _get_message_from_file(filename: str): return Message.deserialize(contents) -class TestSkill(unittest.TestCase): - +class TestSkillMethods(SkillTestCase): @classmethod def setUpClass(cls) -> None: - from mycroft.skills.skill_loader import SkillLoader - - cls.bus = FakeBus() - cls.bus.run_in_thread() - skill_loader = SkillLoader(cls.bus, dirname(dirname(__file__))) - skill_loader.load() - cls.skill = skill_loader.instance - cls.test_fs = join(dirname(__file__), "skill_fs") - if not exists(cls.test_fs): - mkdir(cls.test_fs) - cls.skill.settings_write_path = cls.test_fs - cls.skill.file_system.path = cls.test_fs - - # Override speak and speak_dialog to test passed arguments - cls.skill.speak = Mock() - cls.skill.speak_dialog = Mock() - + SkillTestCase.setUpClass() # Setup alerts load_language("en-us")