Skip to content

Commit

Permalink
Update to resolve local test config bug (#11)
Browse files Browse the repository at this point in the history
Refactor dialog tests to reference skill object instead of files

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Dec 7, 2023
1 parent 7e54bd9 commit 2b71d3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions neon_minerva/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions neon_minerva/tests/test_skill_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import unittest
import os
import json

from os import getenv
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit 2b71d3c

Please sign in to comment.