From b64b9232dbbb5d5a1bd56ac1f1b08f6101113610 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Thu, 7 Dec 2023 12:33:59 -0800 Subject: [PATCH] Update to resolve local test config bug Refactor dialog tests to reference skill object instead of files --- neon_minerva/skill.py | 7 +++++-- neon_minerva/tests/test_skill_resources.py | 13 +++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/neon_minerva/skill.py b/neon_minerva/skill.py index 6106e66..57e2d4d 100644 --- a/neon_minerva/skill.py +++ b/neon_minerva/skill.py @@ -40,11 +40,14 @@ def get_skill_object(skill_entrypoint: str, bus: FakeBus, @param skill_entrypoint: Skill plugin entrypoint or directory path @param bus: FakeBus instance to bind to skill for testing @param skill_id: skill_id to initialize skill with + @param config_patch: Configuration update to apply @returns: Initialized skill object """ if config_patch: - from ovos_config.config import update_mycroft_config - update_mycroft_config(config_patch) + from ovos_config.config import update_mycroft_config, Configuration + user_config = update_mycroft_config(config_patch) + if user_config not in Configuration.xdg_configs: + Configuration.xdg_configs.append(user_config) if isdir(skill_entrypoint): LOG.info(f"Loading local skill: {skill_entrypoint}") from ovos_workshop.skill_launcher import SkillLoader diff --git a/neon_minerva/tests/test_skill_resources.py b/neon_minerva/tests/test_skill_resources.py index afa4a0a..0dedf76 100644 --- a/neon_minerva/tests/test_skill_resources.py +++ b/neon_minerva/tests/test_skill_resources.py @@ -27,7 +27,6 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import unittest -import os import json from os import getenv @@ -84,7 +83,8 @@ def test_skill_setup(self): self.assertEqual(self.skill.skill_id, self.test_skill_id) self.assertEqual(set([self.skill._core_lang] + self.skill._secondary_langs), - set(self.supported_languages)) + set(self.supported_languages), + f"expected={self.supported_languages}") def test_intent_registration(self): registered_adapt = list() @@ -137,8 +137,9 @@ def test_intent_registration(self): def test_dialog_files(self): for lang in self.supported_languages: + dialogs = self.skill._lang_resources[lang].dialog_renderer.templates for dialog in self.dialog: - file = self.skill.find_resource(f"{dialog}.dialog", "dialog", - lang) - self.assertIsInstance(file, str, f"{dialog} in {self.dialog}") - self.assertTrue(os.path.isfile(file), dialog) + self.assertIn(dialog, dialogs.keys(), + f"lang={lang}") + + # TODO: Consider adding tests for resource file existence