Skip to content

Commit

Permalink
Update tests to use shared test class
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Jan 29, 2024
1 parent d598e52 commit edf5f87
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
8 changes: 8 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
neon-minerva[padatious]~=0.1,>=0.1.1a5
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
long_description=long_description,
Expand Down
30 changes: 7 additions & 23 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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")

Expand Down

0 comments on commit edf5f87

Please sign in to comment.