From a73c2ab5f907e07591aff22fcdb5b2e6476f685a Mon Sep 17 00:00:00 2001 From: miro Date: Mon, 8 Apr 2024 20:46:26 +0100 Subject: [PATCH] rm unused tests --- test/end2end/session/test_fallback_v1.py | 177 ------------------ .../skill-ovos-fallback-unknownv1/__init__.py | 12 -- .../locale/en-us/unknown.dialog | 9 - .../skill-ovos-fallback-unknownv1/setup.py | 42 ----- 4 files changed, 240 deletions(-) delete mode 100644 test/end2end/session/test_fallback_v1.py delete mode 100644 test/end2end/skill-ovos-fallback-unknownv1/__init__.py delete mode 100755 test/end2end/skill-ovos-fallback-unknownv1/locale/en-us/unknown.dialog delete mode 100755 test/end2end/skill-ovos-fallback-unknownv1/setup.py diff --git a/test/end2end/session/test_fallback_v1.py b/test/end2end/session/test_fallback_v1.py deleted file mode 100644 index acd55ef1a2c..00000000000 --- a/test/end2end/session/test_fallback_v1.py +++ /dev/null @@ -1,177 +0,0 @@ -import time -from time import sleep -from unittest import TestCase - -from ovos_bus_client.message import Message -from ovos_bus_client.session import SessionManager, Session -from ..minicroft import get_minicroft - - -class TestFallback(TestCase): - - def setUp(self): - self.skill_id = "skill-ovos-fallback-unknownv1.openvoiceos" - self.core = get_minicroft(self.skill_id) - - def tearDown(self) -> None: - self.core.stop() - - def test_fallback_v1(self): - SessionManager.sessions = {} - SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" - SessionManager.default_session.pipeline = [ - "converse", - "fallback_high", - "fallback_medium", - "fallback_low" - ] - messages = [] - - def new_msg(msg): - nonlocal messages - m = Message.deserialize(msg) - if m.msg_type in ["ovos.skills.settings_changed"]: - return # skip these, only happen in 1st run - messages.append(m) - print(len(messages), msg) - - def wait_for_n_messages(n): - nonlocal messages - t = time.time() - while len(messages) < n: - sleep(0.1) - if time.time() - t > 10: - raise RuntimeError("did not get the number of expected messages under 10 seconds") - - self.core.bus.on("message", new_msg) - - utt = Message("recognizer_loop:utterance", - {"utterances": ["invalid"]}, - {"session": SessionManager.default_session.serialize(), # explicit default sess - "x": "xx"}) - self.core.bus.emit(utt) - - # confirm all expected messages are sent - expected_messages = [ - "recognizer_loop:utterance", - # FallbackV1 - high prio - "mycroft.skills.fallback", - "mycroft.skill.handler.start", - "mycroft.skill.handler.complete", - "mycroft.skills.fallback.response", - # FallbackV1 - medium prio - "mycroft.skills.fallback", - "mycroft.skill.handler.start", - "mycroft.skill.handler.complete", - "mycroft.skills.fallback.response", - # FallbackV1 - low prio -> skill selected - "mycroft.skills.fallback", - "mycroft.skill.handler.start", - "enclosure.active_skill", - "speak", - # self activation from skill, instead of from core - "intent.service.skills.activate", - "intent.service.skills.activated", - f"{self.skill_id}.activate", - "ovos.session.update_default", # because it comes from skill - # backwards compat activation for older cores - "active_skill_request", - "intent.service.skills.activated", - f"{self.skill_id}.activate", - "ovos.session.update_default", # because it comes from skill - # report handling - "mycroft.skill.handler.complete", - "mycroft.skills.fallback.response", - # update default sess - "ovos.session.update_default" - ] - wait_for_n_messages(len(expected_messages)) - - self.assertEqual(len(expected_messages), len(messages)) - - mtypes = [m.msg_type for m in messages] - for m in expected_messages: - self.assertTrue(m in mtypes) - - # verify that contexts are kept around - for m in messages: - self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["x"], "xx") - # verify active skills is empty until "intent.service.skills.activated" - for m in messages[:14]: - self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["session"]["active_skills"], []) - - # high prio fallback - self.assertEqual(messages[1].msg_type, "mycroft.skills.fallback") - self.assertEqual(messages[1].data["fallback_range"], [0, 5]) - self.assertEqual(messages[2].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[2].data["handler"], "fallback") - self.assertEqual(messages[3].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[3].data["handler"], "fallback") - self.assertEqual(messages[4].msg_type, "mycroft.skills.fallback.response") - self.assertFalse(messages[4].data["handled"]) - - # medium prio fallback - self.assertEqual(messages[5].msg_type, "mycroft.skills.fallback") - self.assertEqual(messages[5].data["fallback_range"], [5, 90]) - self.assertEqual(messages[6].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[6].data["handler"], "fallback") - self.assertEqual(messages[7].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[7].data["handler"], "fallback") - self.assertEqual(messages[8].msg_type, "mycroft.skills.fallback.response") - self.assertFalse(messages[8].data["handled"]) - - # low prio fallback - self.assertEqual(messages[9].msg_type, "mycroft.skills.fallback") - self.assertEqual(messages[9].data["fallback_range"], [90, 101]) - self.assertEqual(messages[10].msg_type, "mycroft.skill.handler.start") - self.assertEqual(messages[10].data["handler"], "fallback") - - # skill execution - self.assertEqual(messages[11].msg_type, "enclosure.active_skill") - self.assertEqual(messages[11].data["skill_id"], self.skill_id) - self.assertEqual(messages[12].msg_type, "speak") - self.assertEqual(messages[12].data["meta"]["dialog"], "unknown") - self.assertEqual(messages[12].data["meta"]["skill"], self.skill_id) - - # skill making itself active - self.assertEqual(messages[13].msg_type, "intent.service.skills.activate") - self.assertEqual(messages[13].data["skill_id"], self.skill_id) - self.assertEqual(messages[14].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[14].data["skill_id"], self.skill_id) - self.assertEqual(messages[15].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[16].msg_type, 'ovos.session.update_default') - # skill making itself active again - backwards compat namespace - self.assertEqual(messages[17].msg_type, "active_skill_request") - self.assertEqual(messages[17].data["skill_id"], self.skill_id) - self.assertEqual(messages[18].msg_type, "intent.service.skills.activated") - self.assertEqual(messages[18].data["skill_id"], self.skill_id) - self.assertEqual(messages[19].msg_type, f"{self.skill_id}.activate") - self.assertEqual(messages[20].msg_type, 'ovos.session.update_default') - - # fallback execution response - self.assertEqual(messages[21].msg_type, "mycroft.skill.handler.complete") - self.assertEqual(messages[21].data["handler"], "fallback") - self.assertEqual(messages[22].msg_type, "mycroft.skills.fallback.response") - self.assertTrue(messages[22].data["handled"]) - - # verify default session is now updated - self.assertEqual(messages[23].msg_type, "ovos.session.update_default") - self.assertEqual(messages[23].data["session_data"]["session_id"], "default") - - # test second message with no session resumes default active skills - messages = [] - utt = Message("recognizer_loop:utterance", - {"utterances": ["invalid"]}) - self.core.bus.emit(utt) - # converse ping/pong due being active - expected_messages.extend([f"{self.skill_id}.converse.ping", "skill.converse.pong"]) - wait_for_n_messages(len(expected_messages)) - self.assertEqual(len(expected_messages), len(messages)) - - # verify that contexts are kept around - for m in messages[1:]: - self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["session"]["active_skills"][0][0], self.skill_id) diff --git a/test/end2end/skill-ovos-fallback-unknownv1/__init__.py b/test/end2end/skill-ovos-fallback-unknownv1/__init__.py deleted file mode 100644 index 023b4babeac..00000000000 --- a/test/end2end/skill-ovos-fallback-unknownv1/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from ovos_workshop.decorators import fallback_handler -from ovos_workshop.skills.fallback import FallbackSkillV1 - - -# explicitly use class with compat for older cores -# this is usually auto detected, just done here for unittests -class UnknownSkill(FallbackSkillV1): - - @fallback_handler(priority=100) - def handle_fallback(self, message): - self.speak_dialog('unknown') - return True diff --git a/test/end2end/skill-ovos-fallback-unknownv1/locale/en-us/unknown.dialog b/test/end2end/skill-ovos-fallback-unknownv1/locale/en-us/unknown.dialog deleted file mode 100755 index 3f31d7bbc9a..00000000000 --- a/test/end2end/skill-ovos-fallback-unknownv1/locale/en-us/unknown.dialog +++ /dev/null @@ -1,9 +0,0 @@ -I'm sorry, I don't understand. -I don't know what that means. -I don't understand, but I'm learning new things everyday. -Sorry, I didn't catch that. -Sorry, I don't understand. -I don't understand. -I'm not sure I understood you. -You might have to say that a different way. -Please rephrase your request. diff --git a/test/end2end/skill-ovos-fallback-unknownv1/setup.py b/test/end2end/skill-ovos-fallback-unknownv1/setup.py deleted file mode 100755 index dbd2cfc1002..00000000000 --- a/test/end2end/skill-ovos-fallback-unknownv1/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -from os import walk, path - -from setuptools import setup - -URL = "https://github.com/OpenVoiceOS/skill-ovos-fallback-unknownv1" -SKILL_CLAZZ = "UnknownSkill" # needs to match __init__.py class name -PYPI_NAME = "ovos-skill-fallback-unknown-v1" # pip install PYPI_NAME - -# below derived from github url to ensure standard skill_id -SKILL_AUTHOR, SKILL_NAME = URL.split(".com/")[-1].split("/") -SKILL_PKG = SKILL_NAME.lower().replace('-', '_') -PLUGIN_ENTRY_POINT = f'{SKILL_NAME.lower()}.{SKILL_AUTHOR.lower()}={SKILL_PKG}:{SKILL_CLAZZ}' - - -# skill_id=package_name:SkillClass - - -def find_resource_files(): - resource_base_dirs = ("locale", "ui", "vocab", "dialog", "regex", "skill") - base_dir = path.dirname(__file__) - package_data = ["*.json"] - for res in resource_base_dirs: - if path.isdir(path.join(base_dir, res)): - for (directory, _, files) in walk(path.join(base_dir, res)): - if files: - package_data.append( - path.join(directory.replace(base_dir, "").lstrip('/'), - '*')) - return package_data - - -setup( - name=PYPI_NAME, - version="0.0.0", - package_dir={SKILL_PKG: ""}, - package_data={SKILL_PKG: find_resource_files()}, - packages=[SKILL_PKG], - include_package_data=True, - keywords='ovos skill plugin', - entry_points={'ovos.plugin.skill': PLUGIN_ENTRY_POINT} -)