From ee97d74abaeeedf40ee525952b02089b7de1e4ec Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:35:06 +0100 Subject: [PATCH] deprecate ready setting (#554) - https://github.com/OpenVoiceOS/ovos-config/pull/168 - https://github.com/OpenVoiceOS/ovos-bus-client/pull/125 - https://github.com/OpenVoiceOS/ovos-utils/pull/274 companion to https://github.com/OpenVoiceOS/ovos-config/pull/166 --- ovos_core/skill_manager.py | 171 ++---------- requirements/skills-audio.txt | 2 +- .../ovos_tskill_fakewiki/__init__.py | 2 +- .../configuration/__init__.py | 14 - .../configuration/mycroft.conf | 9 - .../configuration/mycroft.json | 234 ---------------- .../configuration/mycroft.yml | 193 ------------- .../configuration/test_configuration.py | 90 ------ test/integrationtests/dialog/__init__.py | 0 .../dialog/multiple_dialogs/one.dialog | 1 - .../dialog/multiple_dialogs/two.dialog | 1 - .../example-context.context.json | 5 - .../mustache_templates/example-context.dialog | 1 - .../mustache_templates/example-context.result | 1 - .../example-simple.context.json | 1 - .../mustache_templates/example-simple.dialog | 1 - .../mustache_templates/example-simple.result | 1 - .../example-comments.dialog | 2 - .../example-comments.result | 1 - .../example-multiple-context.context.json | 3 - .../example-multiple-context.dialog | 3 - .../example-multiple-context.result | 3 - .../example-multiple.context.json | 1 - .../example-multiple.dialog | 3 - .../example-multiple.result | 3 - test/integrationtests/dialog/test_dialog.py | 124 --------- .../intent_file/vocab/en-us/test.intent | 0 .../intent_file/vocab/en-us/test_ent.entity | 0 .../locale/en-us/turn_off2_test.voc | 1 - .../locale/en-us/turn_off_test.voc | 3 - .../ovos_tskill_abort/__init__.py | 2 +- test/integrationtests/test_audioservice.py | 177 ------------ test/integrationtests/test_event_container.py | 68 ----- test/integrationtests/test_event_scheduler.py | 124 --------- test/integrationtests/test_lock.py | 70 ----- test/integrationtests/test_selene_api.py | 2 + test/integrationtests/test_workshop.py | 4 +- .../in-dialog/dialog/en-us/good_things.list | 3 - .../in-dialog/dialog/en-us/named_things.value | 4 - .../in-dialog/dialog/en-us/test.template | 1 - .../in-locale/locale/de-de/good_things.list | 3 - .../in-locale/locale/de-de/named_things.value | 3 - .../in-locale/locale/de-de/test.template | 1 - .../in-locale/locale/en-us/good_things.list | 3 - .../in-locale/locale/en-us/named_things.value | 4 - .../in-locale/locale/en-us/not_in_german.list | 3 - .../in-locale/locale/en-us/test.template | 1 - test/integrationtests/util/__init__.py | 1 - test/integrationtests/util/commented.json | 168 ----------- test/integrationtests/util/muppets.dict | 2 - test/integrationtests/util/plain.json | 135 --------- .../integrationtests/util/test_audio_utils.py | 138 --------- test/integrationtests/util/test_download.py | 109 -------- .../integrationtests/util/test_json_helper.py | 41 --- test/integrationtests/util/test_log.py | 71 ----- .../util/test_monotonic_event.py | 32 --- .../util/test_network_utils.py | 52 ---- test/integrationtests/util/test_parse.py | 263 ------------------ test/integrationtests/util/test_platform.py | 11 - test/integrationtests/util/test_plugins.py | 56 ---- .../util/test_process_utils.py | 205 -------------- test/integrationtests/util/test_signal.py | 49 ---- .../util/test_string_utils.py | 9 - test/integrationtests/util/test_time.py | 91 ------ test/integrationtests/util/test_xdg.py | 27 -- .../util/unstripped_lines.txt | 5 - test/unittests/test_manager.py | 6 - test/unittests/test_skill_manager.py | 2 +- 68 files changed, 25 insertions(+), 2795 deletions(-) delete mode 100644 test/integrationtests/configuration/__init__.py delete mode 100644 test/integrationtests/configuration/mycroft.conf delete mode 100644 test/integrationtests/configuration/mycroft.json delete mode 100644 test/integrationtests/configuration/mycroft.yml delete mode 100644 test/integrationtests/configuration/test_configuration.py delete mode 100644 test/integrationtests/dialog/__init__.py delete mode 100644 test/integrationtests/dialog/multiple_dialogs/one.dialog delete mode 100644 test/integrationtests/dialog/multiple_dialogs/two.dialog delete mode 100644 test/integrationtests/dialog/mustache_templates/example-context.context.json delete mode 100644 test/integrationtests/dialog/mustache_templates/example-context.dialog delete mode 100644 test/integrationtests/dialog/mustache_templates/example-context.result delete mode 100644 test/integrationtests/dialog/mustache_templates/example-simple.context.json delete mode 100644 test/integrationtests/dialog/mustache_templates/example-simple.dialog delete mode 100644 test/integrationtests/dialog/mustache_templates/example-simple.result delete mode 100644 test/integrationtests/dialog/mustache_templates_comments/example-comments.dialog delete mode 100644 test/integrationtests/dialog/mustache_templates_comments/example-comments.result delete mode 100644 test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.context.json delete mode 100644 test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.dialog delete mode 100644 test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.result delete mode 100644 test/integrationtests/dialog/mustache_templates_multiple/example-multiple.context.json delete mode 100644 test/integrationtests/dialog/mustache_templates_multiple/example-multiple.dialog delete mode 100644 test/integrationtests/dialog/mustache_templates_multiple/example-multiple.result delete mode 100644 test/integrationtests/dialog/test_dialog.py delete mode 100644 test/integrationtests/intent_file/vocab/en-us/test.intent delete mode 100644 test/integrationtests/intent_file/vocab/en-us/test_ent.entity delete mode 100644 test/integrationtests/locale/en-us/turn_off2_test.voc delete mode 100644 test/integrationtests/locale/en-us/turn_off_test.voc delete mode 100644 test/integrationtests/test_audioservice.py delete mode 100644 test/integrationtests/test_event_container.py delete mode 100644 test/integrationtests/test_event_scheduler.py delete mode 100644 test/integrationtests/test_lock.py delete mode 100644 test/integrationtests/translate/in-dialog/dialog/en-us/good_things.list delete mode 100644 test/integrationtests/translate/in-dialog/dialog/en-us/named_things.value delete mode 100644 test/integrationtests/translate/in-dialog/dialog/en-us/test.template delete mode 100644 test/integrationtests/translate/in-locale/locale/de-de/good_things.list delete mode 100644 test/integrationtests/translate/in-locale/locale/de-de/named_things.value delete mode 100644 test/integrationtests/translate/in-locale/locale/de-de/test.template delete mode 100644 test/integrationtests/translate/in-locale/locale/en-us/good_things.list delete mode 100644 test/integrationtests/translate/in-locale/locale/en-us/named_things.value delete mode 100644 test/integrationtests/translate/in-locale/locale/en-us/not_in_german.list delete mode 100644 test/integrationtests/translate/in-locale/locale/en-us/test.template delete mode 100644 test/integrationtests/util/__init__.py delete mode 100644 test/integrationtests/util/commented.json delete mode 100644 test/integrationtests/util/muppets.dict delete mode 100644 test/integrationtests/util/plain.json delete mode 100644 test/integrationtests/util/test_audio_utils.py delete mode 100644 test/integrationtests/util/test_download.py delete mode 100644 test/integrationtests/util/test_json_helper.py delete mode 100644 test/integrationtests/util/test_log.py delete mode 100644 test/integrationtests/util/test_monotonic_event.py delete mode 100644 test/integrationtests/util/test_network_utils.py delete mode 100644 test/integrationtests/util/test_parse.py delete mode 100644 test/integrationtests/util/test_platform.py delete mode 100644 test/integrationtests/util/test_plugins.py delete mode 100644 test/integrationtests/util/test_process_utils.py delete mode 100644 test/integrationtests/util/test_signal.py delete mode 100644 test/integrationtests/util/test_string_utils.py delete mode 100644 test/integrationtests/util/test_time.py delete mode 100644 test/integrationtests/util/test_xdg.py delete mode 100644 test/integrationtests/util/unstripped_lines.txt diff --git a/ovos_core/skill_manager.py b/ovos_core/skill_manager.py index fbf28265b11c..e1e2cfb2c784 100644 --- a/ovos_core/skill_manager.py +++ b/ovos_core/skill_manager.py @@ -16,9 +16,9 @@ import os from os.path import basename from threading import Thread, Event, Lock -from time import sleep, monotonic -from ovos_backend_client.pairing import is_paired +from time import monotonic + from ovos_bus_client.apis.enclosure import EnclosureAPI from ovos_bus_client.client import MessageBusClient from ovos_bus_client.message import Message @@ -28,7 +28,7 @@ from ovos_plugin_manager.skills import get_skill_directories from ovos_utils.file_utils import FileWatcher from ovos_utils.gui import is_gui_connected -from ovos_utils.log import LOG +from ovos_utils.log import LOG, deprecated from ovos_utils.network_utils import is_connected from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap, ProcessState from ovos_workshop.skill_launcher import SKILL_MAIN_MODULE @@ -197,7 +197,6 @@ def _define_message_bus_events(self): self.bus.on('skillmanager.deactivate', self.deactivate_skill) self.bus.on('skillmanager.keep', self.deactivate_except) self.bus.on('skillmanager.activate', self.activate_skill) - self.bus.once('mycroft.skills.initialized', self.handle_check_device_readiness) # Load skills waiting for connectivity self.bus.on("mycroft.network.connected", self.handle_network_connected) @@ -207,6 +206,7 @@ def _define_message_bus_events(self): self.bus.on("mycroft.internet.disconnected", self.handle_internet_disconnected) self.bus.on("mycroft.gui.unavailable", self.handle_gui_disconnected) + @deprecated("mycroft.ready event has moved to finished booting skill", "0.1.0") def is_device_ready(self): """Check if the device is ready by waiting for various services to start. @@ -215,44 +215,13 @@ def is_device_ready(self): Raises: TimeoutError: If the device is not ready within a specified timeout. """ - is_ready = False - # Different setups will have different needs - # eg, a server does not care about audio - # pairing -> device is paired - # internet -> device is connected to the internet - NOT IMPLEMENTED - # skills -> skills reported ready - # speech -> stt reported ready - # audio -> audio playback reported ready - # gui -> gui websocket reported ready - NOT IMPLEMENTED - # enclosure -> enclosure/HAL reported ready - NOT IMPLEMENTED - services = {k: False for k in - self.config.get("ready_settings", ["skills"])} - start = monotonic() - while not is_ready: - is_ready = self.check_services_ready(services) - if is_ready: - break - elif monotonic() - start >= 60: - raise TimeoutError( - f'Timeout waiting for services start. services={services}') - else: - sleep(3) - return is_ready + return True + @deprecated("mycroft.ready event has moved to finished booting skill", "0.1.0") def handle_check_device_readiness(self, message): - """Handle the check device readiness event.""" - ready = False - while not ready: - try: - ready = self.is_device_ready() - except TimeoutError: - if is_paired(): - LOG.warning("OVOS should already have reported ready!") - sleep(5) - - LOG.info("Mycroft is all loaded and ready to roll!") - self.bus.emit(message.reply('mycroft.ready')) + pass + @deprecated("mycroft.ready event has moved to finished booting skill", "0.1.0") def check_services_ready(self, services): """Report if all specified services are ready. @@ -261,56 +230,7 @@ def check_services_ready(self, services): Returns: bool: True if all specified services are ready, False otherwise. """ - backend_type = self.config.get("server", {}).get("backend_type", "offline") - for ser, rdy in services.items(): - if rdy: - # already reported ready - continue - if ser in ["pairing", "setup"]: - - def setup_finish_interrupt(message): - nonlocal services - services[ser] = True - - # if setup finishes naturally be ready early - self.bus.once("ovos.setup.finished", setup_finish_interrupt) - - # pairing service (setup skill) needs to be available - # in offline mode (default) is_paired always returns True - # but setup skill may enable backend - # wait for backend selection event - response = self.bus.wait_for_response( - Message('ovos.setup.state.get', - context={"source": "skills", - "destination": "ovos-setup"}), - 'ovos.setup.state') - if response: - state = response.data['state'] - LOG.debug(f"Setup state: {state}") - if state == "finished": - services[ser] = True - elif not services[ser] and backend_type == "selene": - # older verson / alternate setup skill installed - services[ser] = is_paired(ignore_errors=True) - elif ser in ["gui", "enclosure"]: - # not implemented - services[ser] = True - continue - elif ser in ["skills"]: - services[ser] = self.status.check_ready() - continue - elif ser in ["network_skills"]: - services[ser] = self._network_loaded.is_set() - continue - elif ser in ["internet_skills"]: - services[ser] = self._internet_loaded.is_set() - continue - response = self.bus.wait_for_response( - Message(f'mycroft.{ser}.is_ready', - context={"source": "skills", "destination": ser})) - if response and response.data['status']: - services[ser] = True - return all([services[ser] for ser in services]) + return True @property def skills_config(self): @@ -469,86 +389,31 @@ def _load_plugin_skill(self, skill_id, skill_plugin): return skill_loader if load_status else None + @deprecated("priority skills have been deprecated for a long time", "0.1.0") def load_priority(self): - """DEPRECATED: Load priority skills based on the specified order in the configuration.""" - skill_ids = {os.path.basename(skill_path): skill_path - for skill_path in self._get_skill_directories()} - priority_skills = self.skills_config.get("priority_skills") or [] - if priority_skills: - update_code = """priority skills have been deprecated and support will be removed in a future release - Update skills with the following: - - from ovos_utils.process_utils import RuntimeRequirements - from ovos_utils import classproperty - - class MyPrioritySkill(OVOSSkill): - @classproperty - def network_requirements(self): - return RuntimeRequirements(internet_before_load=False, - network_before_load=False, - requires_internet=False, - requires_network=False) - """ - LOG.warning(update_code) - for skill_id in priority_skills: - LOG.info(f"Please refactor {skill_id} to specify offline network requirements") - skill_path = skill_ids.get(skill_id) - if skill_path is not None: - self._load_skill(skill_path) - else: - LOG.error(f'Priority skill {skill_id} can\'t be found') + pass def run(self): """Run the skill manager thread.""" - self.load_priority() - self.status.set_alive() self._load_on_startup() - if self.skills_config.get("wait_for_internet", False): - LOG.warning("`wait_for_internet` is a deprecated option, update to " - "specify `network_skills` or `internet_skills` in " - "`ready_settings`") - # NOTE - self._connected_event will never be set - # if PHAL plugin is not running to emit the connected events - while not self._connected_event.is_set(): - # Ensure we don't block here forever if the plugin is not installed - self._sync_skill_loading_state() - sleep(1) - LOG.debug("Internet Connected") - else: - # trigger a sync so we dont need to wait for the plugin to volunteer info - self._sync_skill_loading_state() + # trigger a sync so we dont need to wait for the plugin to volunteer info + self._sync_skill_loading_state() - if "network_skills" in self.config.get("ready_settings"): - self._network_event.wait() # Wait for user to connect to network - if self._network_loaded.wait(self._network_skill_timeout): - LOG.debug("Network skills loaded") - else: - LOG.error("Gave up waiting for network skills to load") - if "internet_skills" in self.config.get("ready_settings"): - self._connected_event.wait() # Wait for user to connect to network - if self._internet_loaded.wait(self._network_skill_timeout): - LOG.debug("Internet skills loaded") - else: - LOG.error("Gave up waiting for internet skills to load") if not all((self._network_loaded.is_set(), self._internet_loaded.is_set())): self.bus.emit(Message( 'mycroft.skills.error', {'internet_loaded': self._internet_loaded.is_set(), 'network_loaded': self._network_loaded.is_set()})) + self.bus.emit(Message('mycroft.skills.initialized')) self.status.set_ready() - if self._gui_event.is_set() and self._connected_event.is_set(): - LOG.info("Skills all loaded!") - elif not self._connected_event.is_set(): - LOG.info("Offline Skills loaded, waiting for Internet to load more!") - elif not self._gui_event.is_set(): - LOG.info("Skills loaded, waiting for GUI to load more!") + LOG.info("ovos-core is ready! additional skills can now be loaded") # Scan the file folder that contains Skills. If a Skill is updated, # unload the existing version from memory and reload from the disk. @@ -564,14 +429,14 @@ def run(self): def _load_on_network(self): """Load skills that require a network connection.""" - if self._detected_installed_skills: # ensure we have skills is installed + if self._detected_installed_skills: # ensure we have skills installed LOG.info('Loading skills that require network...') self._load_new_skills(network=True, internet=False) self._network_loaded.set() def _load_on_internet(self): """Load skills that require both internet and network connections.""" - if self._detected_installed_skills: # ensure we have skills is installed + if self._detected_installed_skills: # ensure we have skills installed LOG.info('Loading skills that require internet (and network)...') self._load_new_skills(network=True, internet=True) self._internet_loaded.set() @@ -615,7 +480,7 @@ def _unload_on_gui_disconnect(self): def _load_on_startup(self): """Handle offline skills load on startup.""" - if self._detected_installed_skills: # ensure we have skills is installed + if self._detected_installed_skills: # ensure we have skills installed LOG.info('Loading offline skills...') self._load_new_skills(network=False, internet=False) diff --git a/requirements/skills-audio.txt b/requirements/skills-audio.txt index 8516c95b9bab..b71f3c7bf637 100644 --- a/requirements/skills-audio.txt +++ b/requirements/skills-audio.txt @@ -1,5 +1,5 @@ # skills that run in audio enabled devices (require mic/speaker) -ovos-skill-boot-finished>=0.2.1,<1.0.0 +ovos-skill-boot-finished>=0.3.0,<1.0.0 ovos-skill-audio-recording>=0.2.2,<1.0.0 ovos-skill-dictation>=0.2.0,<1.0.0 ovos-skill-parrot>=0.1.2,<1.0.0 diff --git a/test/integrationtests/common_query/ovos_tskill_fakewiki/__init__.py b/test/integrationtests/common_query/ovos_tskill_fakewiki/__init__.py index 48c0212e50f2..ca8fee4af70f 100644 --- a/test/integrationtests/common_query/ovos_tskill_fakewiki/__init__.py +++ b/test/integrationtests/common_query/ovos_tskill_fakewiki/__init__.py @@ -1,7 +1,7 @@ from ovos_adapt.intent import IntentBuilder from ovos_workshop.skills.common_query_skill import CommonQuerySkill, CQSMatchLevel -from mycroft.skills.core import intent_handler +from ovos_workshop.decorators import intent_handler class FakeWikiSkill(CommonQuerySkill): diff --git a/test/integrationtests/configuration/__init__.py b/test/integrationtests/configuration/__init__.py deleted file mode 100644 index b5d9e70242d7..000000000000 --- a/test/integrationtests/configuration/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2017 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/test/integrationtests/configuration/mycroft.conf b/test/integrationtests/configuration/mycroft.conf deleted file mode 100644 index cbb649ab6980..000000000000 --- a/test/integrationtests/configuration/mycroft.conf +++ /dev/null @@ -1,9 +0,0 @@ -{ - "lang": "pt-br", - "tts": { - "module": "espeak", - "espeak": { - "voice": "f1" - } - } -} diff --git a/test/integrationtests/configuration/mycroft.json b/test/integrationtests/configuration/mycroft.json deleted file mode 100644 index f54fee213d6a..000000000000 --- a/test/integrationtests/configuration/mycroft.json +++ /dev/null @@ -1,234 +0,0 @@ -{ - "Audio": { - "backends": { - "OCP": { - "active": true, - "type": "ovos_common_play" - }, - "simple": { - "active": true, - "type": "ovos_audio_simple" - }, - "vlc": { - "active": true, - "type": "ovos_vlc" - } - }, - "default-backend": "OCP" - }, - "cache_path": "/tmp/mycroft/cache", - "confirm_listening": true, - "date_format": "MDY", - "debug": false, - "enclosure": { - "force_mycroft_ntp": true, - "ntp_sync_on_boot": false, - "platform": "PHAL" - }, - "gui": { - "extension": "generic", - "generic": { - "homescreen_supported": false - } - }, - "gui_websocket": { - "base_port": 18181, - "host": "0.0.0.0", - "route": "/gui", - "ssl": false - }, - "hotwords": { - "hey mycroft": { - "lang": "en-us", - "listen": true, - "model": "https://github.com/MycroftAI/precise-data/raw/models-dev/hey-mycroft.tar.gz", - "module": "ovos-ww-plugin-precise", - "phonemes": "HH EY . M AY K R AO F T", - "sound": "snd/start_listening.wav", - "threshold": 1e-90, - "version": "0.3" - }, - "wake up": { - "lang": "en-us", - "module": "ovos-ww-plugin-pocketsphinx", - "phonemes": "W EY K . AH P", - "threshold": 1e-20, - "wakeup": true - } - }, - "ignore_logs": [ - "enclosure.mouth.viseme", - "enclosure.mouth.display" - ], - "lang": "en-us", - "listener": { - "VAD": { - "before_seconds": 0.5, - "initial_energy_threshold": 1000.0, - "max_current_ratio_threshold": 2, - "min_seconds": 1, - "module": "", - "ovos-vad-plugin-silero": { - "threshold": 0.2 - }, - "ovos-vad-plugin-webrtcvad": { - "vad_mode": 3 - }, - "silence_method": "vad_and_ratio", - "silence_seconds": 0.5, - "speech_seconds": 0.1 - }, - "duck_while_listening": 0.3, - "energy_ratio": 1.5, - "instant_listen": false, - "mic_meter_ipc": true, - "multiplier": 1.0, - "mute_during_output": true, - "phoneme_duration": 120, - "record_wake_words": false, - "recording_timeout": 10.0, - "recording_timeout_with_silence": 3.0, - "sample_rate": 16000, - "save_utterances": false, - "wake_word_upload": { - "disable": false, - "url": "https://training.mycroft.ai/precise/upload" - } - }, - "location": { - "city": { - "code": "Lawrence", - "name": "Lawrence", - "state": { - "code": "KS", - "country": { - "code": "US", - "name": "United States" - }, - "name": "Kansas" - } - }, - "coordinate": { - "latitude": 38.971669, - "longitude": -95.23525 - }, - "timezone": { - "code": "America/Chicago", - "dstOffset": 3600000, - "name": "Central Standard Time", - "offset": -21600000 - } - }, - "network_tests": { - "dns_primary": "8.8.8.8", - "dns_secondary": "8.8.4.4", - "ncsi_endpoint": "http://www.msftncsi.com/ncsi.txt", - "ncsi_expected_text": "Microsoft NCSI", - "web_url": "https://www.google.com" - }, - "opt_in": false, - "padatious": { - "intent_cache": "~/.local/share/mycroft/intent_cache", - "padaos_only": false, - "single_thread": false, - "train_delay": 4 - }, - "play_mp3_cmdline": "mpg123 %1", - "play_ogg_cmdline": "ogg123 -q %1", - "play_wav_cmdline": "paplay %1 --stream-name=mycroft-voice", - "precise": { - "dist_url": "https://github.com/MycroftAI/precise-data/raw/dist/{arch}/latest", - "model_url": "https://raw.githubusercontent.com/MycroftAI/precise-data/models/{wake_word}.tar.gz", - "use_precise": true - }, - "ready_settings": [ - "skills" - ], - "server": { - "disabled": true, - "metrics": false, - "sync_skill_settings": true, - "update": false, - "url": "https://api.mycroft.ai", - "version": "v1" - }, - "session": { - "ttl": 180 - }, - "skills": { - "blacklisted_skills": [], - "converse": { - "converse_activation": "accept_all", - "converse_blacklist": [], - "converse_mode": "accept_all", - "converse_priorities": {}, - "converse_whitelist": [], - "cross_activation": true, - "cross_deactivation": true, - "max_activations": -1, - "skill_activations": {}, - "skill_timeouts": {}, - "timeout": 300 - }, - "directory": "skills", - "fallbacks": { - "fallback_blacklist": [], - "fallback_mode": "accept_all", - "fallback_priorities": {}, - "fallback_whitelist": [] - }, - "priority_skills": [ - "mycroft-pairing", - "mycroft-volume" - ], - "upload_skill_manifest": true, - "wait_for_internet": false - }, - "sounds": { - "acknowledge": "snd/acknowledge.mp3", - "end_listening": "snd/end_listening.wav", - "start_listening": "snd/start_listening.wav" - }, - "stt": { - "fallback_module": "ovos-stt-plugin-vosk", - "module": "ovos-stt-plugin-server", - "ovos-stt-plugin-server": { - "url": "https://stt.openvoiceos.com/stt" - } - }, - "system": { - "disable_remote_config": false, - "disable_user_config": false, - "protected_keys": { - "remote": [ - "enclosure", - "server", - "system", - "websocket", - "gui_websocket", - "network_tests", - "listener:wake_word_upload:disable", - "skills:upload_skill_manifest", - "skills:auto_update", - "skills:priority_skills", - "skills:blacklisted_skills", - "opt_in" - ], - "user": [] - } - }, - "system_unit": "metric", - "time_format": "half", - "tts": { - "fallback_module": "ovos-tts-plugin-mimic", - "module": "ovos-tts-plugin-mimic2", - "pulse_duck": false - }, - "websocket": { - "host": "0.0.0.0", - "port": 8181, - "route": "/core", - "shared_connection": true, - "ssl": false - } -} \ No newline at end of file diff --git a/test/integrationtests/configuration/mycroft.yml b/test/integrationtests/configuration/mycroft.yml deleted file mode 100644 index 6e5a41247fd6..000000000000 --- a/test/integrationtests/configuration/mycroft.yml +++ /dev/null @@ -1,193 +0,0 @@ -Audio: - backends: - OCP: - active: true - type: ovos_common_play - simple: - active: true - type: ovos_audio_simple - vlc: - active: true - type: ovos_vlc - default-backend: OCP -cache_path: /tmp/mycroft/cache -confirm_listening: true -date_format: MDY -debug: false -enclosure: - force_mycroft_ntp: true - ntp_sync_on_boot: false - platform: PHAL -gui: - extension: generic - generic: - homescreen_supported: false -gui_websocket: - base_port: 18181 - host: 0.0.0.0 - route: /gui - ssl: false -hotwords: - hey mycroft: { - "lang": "en-us", - "listen": true, - "model": "https://github.com/MycroftAI/precise-data/raw/models-dev/hey-mycroft.tar.gz", - "module": "ovos-ww-plugin-precise", - "phonemes": "HH EY . M AY K R AO F T", - "sound": "snd/start_listening.wav", - "threshold": 1.0e-90, - "version": '0.3' - } - - wake up: - # Handles the "wake up" hotword when Mycroft is sleeping - lang: en-us - module: ovos-ww-plugin-pocketsphinx - phonemes: W EY K . AH P - threshold: 1.0e-20 - wakeup: true -ignore_logs: - - enclosure.mouth.viseme - - enclosure.mouth.display -lang: en-us -listener: - VAD: - before_seconds: 0.5 - initial_energy_threshold: 1000.0 - max_current_ratio_threshold: 2 - min_seconds: 1 - module: '' - ovos-vad-plugin-silero: - threshold: 0.2 - ovos-vad-plugin-webrtcvad: - vad_mode: 3 - silence_method: vad_and_ratio - silence_seconds: 0.5 - speech_seconds: 0.1 - duck_while_listening: 0.3 - energy_ratio: 1.5 - instant_listen: false - mic_meter_ipc: true - multiplier: 1.0 - mute_during_output: true - phoneme_duration: 120 - record_wake_words: false - recording_timeout: 10.0 - recording_timeout_with_silence: 3.0 - sample_rate: 16000 - save_utterances: false - wake_word_upload: - disable: false - url: https://training.mycroft.ai/precise/upload -location: - city: - code: Lawrence - name: Lawrence - state: - code: KS - country: - code: US - name: United States - name: Kansas - coordinate: - latitude: 38.971669 - longitude: -95.23525 - timezone: - code: America/Chicago - dstOffset: 3600000 - name: Central Standard Time - offset: -21600000 -network_tests: - dns_primary: 8.8.8.8 - dns_secondary: 8.8.4.4 - ncsi_endpoint: http://www.msftncsi.com/ncsi.txt - ncsi_expected_text: Microsoft NCSI - web_url: https://www.google.com -opt_in: false -padatious: - intent_cache: ~/.local/share/mycroft/intent_cache - padaos_only: false - single_thread: false - train_delay: 4 -play_mp3_cmdline: mpg123 %1 -play_ogg_cmdline: ogg123 -q %1 -play_wav_cmdline: paplay %1 --stream-name=mycroft-voice -precise: - dist_url: https://github.com/MycroftAI/precise-data/raw/dist/{arch}/latest - model_url: https://raw.githubusercontent.com/MycroftAI/precise-data/models/{wake_word}.tar.gz - use_precise: true -ready_settings: - - skills -server: - disabled: true - metrics: false - sync_skill_settings: true - update: false - url: https://api.mycroft.ai - version: v1 -session: - ttl: 180 -skills: - blacklisted_skills: [ ] - converse: - converse_activation: accept_all - converse_blacklist: [ ] - converse_mode: accept_all - converse_priorities: { } - converse_whitelist: [ ] - cross_activation: true - cross_deactivation: true - max_activations: -1 - skill_activations: { } - skill_timeouts: { } - timeout: 300 - directory: skills - fallbacks: - fallback_blacklist: [ ] - fallback_mode: accept_all - fallback_priorities: { } - fallback_whitelist: [ ] - priority_skills: - - mycroft-pairing - - mycroft-volume - upload_skill_manifest: true - wait_for_internet: false -sounds: - acknowledge: snd/acknowledge.mp3 - end_listening: snd/end_listening.wav - start_listening: snd/start_listening.wav -stt: - fallback_module: ovos-stt-plugin-vosk - module: ovos-stt-plugin-server - ovos-stt-plugin-server: - url: https://stt.openvoiceos.com/stt -system: - disable_remote_config: false - disable_user_config: false - protected_keys: - remote: - - enclosure - - server - - system - - websocket - - gui_websocket - - network_tests - - listener:wake_word_upload:disable - - skills:upload_skill_manifest - - skills:auto_update - - skills:priority_skills - - skills:blacklisted_skills - - opt_in - user: [ ] -system_unit: metric -time_format: half -tts: - fallback_module: ovos-tts-plugin-mimic - module: ovos-tts-plugin-mimic2 - pulse_duck: false -websocket: - host: 0.0.0.0 - port: 8181 - route: /core - shared_connection: true - ssl: false diff --git a/test/integrationtests/configuration/test_configuration.py b/test/integrationtests/configuration/test_configuration.py deleted file mode 100644 index 115d3b2fe784..000000000000 --- a/test/integrationtests/configuration/test_configuration.py +++ /dev/null @@ -1,90 +0,0 @@ -import json -from os.path import dirname, isfile -from typing import OrderedDict -from unittest import TestCase -from unittest.mock import MagicMock, patch - -from ovos_config import LocalConf, RemoteConf - - -# TODO - move to ovos-config -class TestConfiguration(TestCase): - - @patch('ovos_backend_client.config.RemoteConfigManager') - @patch('ovos_backend_client.pairing.is_paired') - def test_remote(self, is_paired, config_manager): - remote_conf = {'TestConfig': True, 'uuid': 1234, - 'location': {'city': {'name': 'Stockholm'}}} - is_paired.return_value = True - - mock_api = MagicMock() - mock_api.config = remote_conf - config_manager.return_value = mock_api - - rc = RemoteConf() - rc.reload() - mock_api.download.assert_called_once() - is_paired.assert_called_once() - - self.assertTrue(rc['TestConfig']) - self.assertEqual(rc['location']['city']['name'], 'Stockholm') - - @patch('json.dump') - @patch('ovos_config.models.exists') - @patch('ovos_config.models.isfile') - @patch('ovos_config.models.load_commented_json') - def test_local(self, mock_json_loader, mock_isfile, mock_exists, - mock_json_dump): - local_conf = {'answer': 42, 'falling_objects': ['flower pot', 'whale']} - mock_exists.return_value = True - mock_isfile.return_value = True - mock_json_loader.return_value = local_conf - lc = LocalConf('test') - self.assertEqual(lc, local_conf) - - # Test merge method - merge_conf = {'falling_objects': None, 'has_towel': True} - lc.merge(merge_conf) - self.assertEqual(lc['falling_objects'], None) - self.assertEqual(lc['has_towel'], True) - - # test store - lc.store('test_conf.json') - self.assertEqual(mock_json_dump.call_args[0][0], lc) - # exists but is not file - mock_isfile.return_value = False - lc = LocalConf('test') - self.assertEqual(lc, {}) - - # does not exist - mock_exists.return_value = False - lc = LocalConf('test') - self.assertEqual(lc, {}) - - def test_file_formats(self): - yml_cnf = LocalConf(f"{dirname(__file__)}/mycroft.yml") - json_config = LocalConf(f"{dirname(__file__)}/mycroft.json") - self.assertEqual(json_config, yml_cnf) - - # test export json config as yaml - json_config.store("/tmp/not_mycroft.yml") - self.assertTrue(isfile("/tmp/not_mycroft.yml")) - test_conf = LocalConf("/tmp/not_mycroft.yml") - self.assertEqual(test_conf, yml_cnf) - self.assertEqual(test_conf, json_config) - - # test export yaml config as json - yml_cnf.store("/tmp/not_mycroft.json") - self.assertTrue(isfile("/tmp/not_mycroft.json")) - test_conf = LocalConf("/tmp/not_mycroft.json") - self.assertEqual(test_conf, yml_cnf) - self.assertEqual(test_conf, json_config) - - def test_yaml_config_load(self): - yml_cnf = LocalConf(f"{dirname(__file__)}/mycroft.yml") - for d in (yml_cnf, yml_cnf["hotwords"], - yml_cnf["hotwords"]["hey mycroft"], - yml_cnf["hotwords"]["wake up"]): - self.assertIsInstance(d, dict) - self.assertNotIsInstance(d, OrderedDict) - self.assertEqual(json.loads(json.dumps(d)), d) diff --git a/test/integrationtests/dialog/__init__.py b/test/integrationtests/dialog/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/test/integrationtests/dialog/multiple_dialogs/one.dialog b/test/integrationtests/dialog/multiple_dialogs/one.dialog deleted file mode 100644 index a2628c1e0953..000000000000 --- a/test/integrationtests/dialog/multiple_dialogs/one.dialog +++ /dev/null @@ -1 +0,0 @@ -ONE diff --git a/test/integrationtests/dialog/multiple_dialogs/two.dialog b/test/integrationtests/dialog/multiple_dialogs/two.dialog deleted file mode 100644 index 6333d309717a..000000000000 --- a/test/integrationtests/dialog/multiple_dialogs/two.dialog +++ /dev/null @@ -1 +0,0 @@ -TWO diff --git a/test/integrationtests/dialog/mustache_templates/example-context.context.json b/test/integrationtests/dialog/mustache_templates/example-context.context.json deleted file mode 100644 index 091539d7728e..000000000000 --- a/test/integrationtests/dialog/mustache_templates/example-context.context.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Chris", - "value": 10000, - "taxed_value": 6000 -} diff --git a/test/integrationtests/dialog/mustache_templates/example-context.dialog b/test/integrationtests/dialog/mustache_templates/example-context.dialog deleted file mode 100644 index aecabb10a8d9..000000000000 --- a/test/integrationtests/dialog/mustache_templates/example-context.dialog +++ /dev/null @@ -1 +0,0 @@ -Hello {{name}}, You have just won {{value}} dollars! Well, {{taxed_value}} dollars, after taxes. \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates/example-context.result b/test/integrationtests/dialog/mustache_templates/example-context.result deleted file mode 100644 index 0183799c7dc4..000000000000 --- a/test/integrationtests/dialog/mustache_templates/example-context.result +++ /dev/null @@ -1 +0,0 @@ -Hello Chris, You have just won 10000 dollars! Well, 6000 dollars, after taxes. \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates/example-simple.context.json b/test/integrationtests/dialog/mustache_templates/example-simple.context.json deleted file mode 100644 index 9e26dfeeb6e6..000000000000 --- a/test/integrationtests/dialog/mustache_templates/example-simple.context.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates/example-simple.dialog b/test/integrationtests/dialog/mustache_templates/example-simple.dialog deleted file mode 100644 index cd773cd131fc..000000000000 --- a/test/integrationtests/dialog/mustache_templates/example-simple.dialog +++ /dev/null @@ -1 +0,0 @@ -Hello there! \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates/example-simple.result b/test/integrationtests/dialog/mustache_templates/example-simple.result deleted file mode 100644 index cd773cd131fc..000000000000 --- a/test/integrationtests/dialog/mustache_templates/example-simple.result +++ /dev/null @@ -1 +0,0 @@ -Hello there! \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates_comments/example-comments.dialog b/test/integrationtests/dialog/mustache_templates_comments/example-comments.dialog deleted file mode 100644 index 114efa33e938..000000000000 --- a/test/integrationtests/dialog/mustache_templates_comments/example-comments.dialog +++ /dev/null @@ -1,2 +0,0 @@ -# This is a commented line -This is a line without comment diff --git a/test/integrationtests/dialog/mustache_templates_comments/example-comments.result b/test/integrationtests/dialog/mustache_templates_comments/example-comments.result deleted file mode 100644 index 30246649ead5..000000000000 --- a/test/integrationtests/dialog/mustache_templates_comments/example-comments.result +++ /dev/null @@ -1 +0,0 @@ -This is a line without comment diff --git a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.context.json b/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.context.json deleted file mode 100644 index 1fd6fbf5b530..000000000000 --- a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.context.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Sherlock" -} \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.dialog b/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.dialog deleted file mode 100644 index 70d5611ca410..000000000000 --- a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.dialog +++ /dev/null @@ -1,3 +0,0 @@ -Hello there {{name}}! -Another possible outcome, {{name}} -Oh, {{name}} look at the capabilities \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.result b/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.result deleted file mode 100644 index ea3370bbfa8b..000000000000 --- a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple-context.result +++ /dev/null @@ -1,3 +0,0 @@ -Hello there Sherlock! -Another possible outcome, Sherlock -Oh, Sherlock look at the capabilities diff --git a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.context.json b/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.context.json deleted file mode 100644 index 9e26dfeeb6e6..000000000000 --- a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.context.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.dialog b/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.dialog deleted file mode 100644 index 2f0581807c60..000000000000 --- a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.dialog +++ /dev/null @@ -1,3 +0,0 @@ -Hello there! -Another possible outcome -Oh look at the capabilities \ No newline at end of file diff --git a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.result b/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.result deleted file mode 100644 index 267860fd3c6b..000000000000 --- a/test/integrationtests/dialog/mustache_templates_multiple/example-multiple.result +++ /dev/null @@ -1,3 +0,0 @@ -Hello there! -Another possible outcome -Oh look at the capabilities diff --git a/test/integrationtests/dialog/test_dialog.py b/test/integrationtests/dialog/test_dialog.py deleted file mode 100644 index 5343f5c386db..000000000000 --- a/test/integrationtests/dialog/test_dialog.py +++ /dev/null @@ -1,124 +0,0 @@ -# -# Copyright 2017 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import json -import pathlib -import unittest - -from mycroft.dialog import get -from ovos_utils.dialog import MustacheDialogRenderer, load_dialogs -from ovos_utils.file_utils import resolve_resource_file - - -# TODO - move to ovos-utils -class DialogTest(unittest.TestCase): - def setUp(self): - self.stache = MustacheDialogRenderer() - self.topdir = pathlib.Path(__file__).parent - - def test_general_dialog(self): - """ Test the loading and filling of valid simple mustache dialogs """ - template_path = self.topdir.joinpath('./mustache_templates') - for file in template_path.iterdir(): - if file.suffix == '.dialog': - self.stache.load_template_file(file.name, str(file.absolute())) - context = json.load( - file.with_suffix('.context.json').open( - 'r', encoding='utf-8')) - self.assertEqual( - self.stache.render(file.name, context), - file.with_suffix('.result').open('r', - encoding='utf-8').read()) - - def test_unknown_dialog(self): - """ Test for returned file name literals in case of unkown dialog """ - self.assertEqual( - self.stache.render("unknown.template"), "unknown template") - - def test_multiple_dialog(self): - """ - Test the loading and filling of valid mustache dialogs - where a dialog file contains multiple text versions - """ - template_path = self.topdir.joinpath('./mustache_templates_multiple') - for file in template_path.iterdir(): - if file.suffix == '.dialog': - self.stache.load_template_file(file.name, str(file.absolute())) - context = json.load( - file.with_suffix('.context.json').open( - 'r', encoding='utf-8')) - results = [ - line.strip() for line in file.with_suffix('.result').open( - 'r', encoding='utf-8') - ] - # Try all lines - for index, line in enumerate(results): - self.assertEqual( - self.stache.render( - file.name, index=index, context=context), - line.strip()) - # Test random index function - # (bad test because non-deterministic?) - self.assertIn( - self.stache.render(file.name, context=context), results) - - def test_comment_dialog(self): - """ - Test the loading and filling of valid mustache dialogs - where a dialog file contains multiple text versions - """ - template_path = self.topdir.joinpath('./mustache_templates_comments') - for f in template_path.iterdir(): - if f.suffix == '.dialog': - self.stache.load_template_file(f.name, str(f.absolute())) - results = [line.strip() - for line in f.with_suffix('.result').open('r')] - # Try all lines - for index, line in enumerate(results): - self.assertEqual(self.stache.render(f.name, index=index), - line.strip()) - - def test_dialog_loader(self): - template_path = self.topdir.joinpath('./multiple_dialogs') - renderer = load_dialogs(template_path) - self.assertEqual(renderer.render('one'), 'ONE') - self.assertEqual(renderer.render('two'), 'TWO') - - def test_dialog_loader_missing(self): - template_path = self.topdir.joinpath('./missing_dialogs') - renderer = load_dialogs(template_path) - self.assertEqual(renderer.render('test'), 'test') - - def test_get(self): - phrase = 'i didn\'t catch that' - res_file = pathlib.Path('text/en-us/').joinpath(phrase + '.dialog') - - resource = resolve_resource_file(str(res_file)) - with open(resource) as f: - results = [line.strip() for line in f] - string = get(phrase) - self.assertIn(string, results) - - # Check that the filename is returned if phrase is missing for lang - string = get(phrase, lang='ne-ne') - self.assertEqual(string, phrase) - - # Check that name is retured if phrase is missing - string = get('testing aardwark') - self.assertEqual(string, 'testing aardwark') - - -if __name__ == "__main__": - unittest.main() diff --git a/test/integrationtests/intent_file/vocab/en-us/test.intent b/test/integrationtests/intent_file/vocab/en-us/test.intent deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/test/integrationtests/intent_file/vocab/en-us/test_ent.entity b/test/integrationtests/intent_file/vocab/en-us/test_ent.entity deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/test/integrationtests/locale/en-us/turn_off2_test.voc b/test/integrationtests/locale/en-us/turn_off2_test.voc deleted file mode 100644 index d06334097793..000000000000 --- a/test/integrationtests/locale/en-us/turn_off2_test.voc +++ /dev/null @@ -1 +0,0 @@ -(turn off|switch off) diff --git a/test/integrationtests/locale/en-us/turn_off_test.voc b/test/integrationtests/locale/en-us/turn_off_test.voc deleted file mode 100644 index 8dde42090206..000000000000 --- a/test/integrationtests/locale/en-us/turn_off_test.voc +++ /dev/null @@ -1,3 +0,0 @@ -turn off -switch off - diff --git a/test/integrationtests/ovos_tskill_abort/__init__.py b/test/integrationtests/ovos_tskill_abort/__init__.py index 4cb618ccffbd..ea1059fef4d9 100644 --- a/test/integrationtests/ovos_tskill_abort/__init__.py +++ b/test/integrationtests/ovos_tskill_abort/__init__.py @@ -1,6 +1,6 @@ from ovos_workshop.decorators import killable_intent from ovos_workshop.skills.ovos import OVOSSkill -from mycroft.skills import intent_file_handler +from ovos_workshop.decorators import intent_file_handler from time import sleep diff --git a/test/integrationtests/test_audioservice.py b/test/integrationtests/test_audioservice.py deleted file mode 100644 index c2a69cca86d3..000000000000 --- a/test/integrationtests/test_audioservice.py +++ /dev/null @@ -1,177 +0,0 @@ -from unittest import TestCase, mock - -# TODO - move test to ovos-bus-client -from ovos_bus_client.message import Message -from ovos_bus_client.apis.ocp import ClassicAudioServiceInterface as AudioService - - -class TestAudioServiceControls(TestCase): - def assertLastMessageTypeEqual(self, bus, msg_type): - message = bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, msg_type) - - def setUp(self): - self.bus = mock.Mock(name='bus') - self.audioservice = AudioService(self.bus) - - def test_pause(self): - self.audioservice.pause() - self.assertLastMessageTypeEqual(self.bus, - 'mycroft.audio.service.pause') - - def test_resume(self): - self.audioservice.resume() - self.assertLastMessageTypeEqual(self.bus, - 'mycroft.audio.service.resume') - - def test_next(self): - self.audioservice.next() - self.assertLastMessageTypeEqual(self.bus, 'mycroft.audio.service.next') - - def test_prev(self): - self.audioservice.prev() - self.assertLastMessageTypeEqual(self.bus, 'mycroft.audio.service.prev') - - def test_stop(self): - self.audioservice.stop() - self.assertLastMessageTypeEqual(self.bus, 'mycroft.audio.service.stop') - - def test_seek(self): - self.audioservice.seek() - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, - 'mycroft.audio.service.seek_forward') - self.assertEqual(message.data['seconds'], 1) - self.audioservice.seek(5) - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, - 'mycroft.audio.service.seek_forward') - self.assertEqual(message.data['seconds'], 5) - self.audioservice.seek(-5) - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, - 'mycroft.audio.service.seek_backward') - self.assertEqual(message.data['seconds'], 5) - - -class TestAudioServicePlay(TestCase): - def setUp(self): - self.bus = mock.Mock(name='bus') - self.audioservice = AudioService(self.bus) - - def test_proper_uri(self): - self.audioservice.play('file:///hello_nasty.mp3') - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, 'mycroft.audio.service.play') - self.assertEqual(message.data['tracks'], ['file:///hello_nasty.mp3']) - self.assertEqual(message.data['repeat'], False) - - def test_path(self): - self.audioservice.play('/hello_nasty.mp3') - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, 'mycroft.audio.service.play') - self.assertEqual(message.data['tracks'], ['file:///hello_nasty.mp3']) - self.assertEqual(message.data['repeat'], False) - - def test_tuple(self): - """Test path together with mimetype.""" - self.audioservice.play(('/hello_nasty.mp3', 'audio/mp3')) - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, 'mycroft.audio.service.play') - self.assertEqual(message.data['tracks'], - [('file:///hello_nasty.mp3', 'audio/mp3')]) - self.assertEqual(message.data['repeat'], False) - - def test_invalid(self): - """Test play request with invalid type.""" - with self.assertRaises(ValueError): - self.audioservice.play(12) - - def test_extra_arguments(self): - """Test sending along utterance and setting repeat.""" - self.audioservice.play('/hello_nasty.mp3', 'on vlc', True) - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, 'mycroft.audio.service.play') - self.assertEqual(message.data['tracks'], ['file:///hello_nasty.mp3']) - self.assertEqual(message.data['repeat'], True) - self.assertEqual(message.data['utterance'], 'on vlc') - - -class TestAudioServiceQueue(TestCase): - def setUp(self): - self.bus = mock.Mock(name='bus') - self.audioservice = AudioService(self.bus) - - def test_uri(self): - self.audioservice.queue('file:///hello_nasty.mp3') - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, 'mycroft.audio.service.queue') - self.assertEqual(message.data['tracks'], ['file:///hello_nasty.mp3']) - - def test_path(self): - self.audioservice.queue('/hello_nasty.mp3') - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, 'mycroft.audio.service.queue') - self.assertEqual(message.data['tracks'], ['file:///hello_nasty.mp3']) - - def test_tuple(self): - self.audioservice.queue(('/hello_nasty.mp3', 'audio/mp3')) - message = self.bus.emit.call_args_list[-1][0][0] - self.assertEqual(message.msg_type, 'mycroft.audio.service.queue') - self.assertEqual(message.data['tracks'], - [('file:///hello_nasty.mp3', 'audio/mp3')]) - - def test_invalid(self): - with self.assertRaises(ValueError): - self.audioservice.queue(12) - - -class TestAudioServiceMisc(TestCase): - def test_lifecycle(self): - bus = mock.Mock(name='bus') - audioservice = AudioService(bus) - self.assertEqual(audioservice.bus, bus) - - def test_available_backends(self): - bus = mock.Mock(name='bus') - audioservice = AudioService(bus) - - available_backends = { - 'simple': { - 'suported_uris': ['http', 'file'], - 'default': True, - 'remote': False - } - } - bus.wait_for_response.return_value = Message('test_msg', - available_backends) - response = audioservice.available_backends() - self.assertEqual(available_backends, response) - # Check no response behaviour - bus.wait_for_response.return_value = None - response = audioservice.available_backends() - self.assertEqual({}, response) - - def test_track_info(self): - """Test is_playing property.""" - bus = mock.Mock(name='bus') - audioservice = AudioService(bus) - info = {'album': 'Hello Nasty', - 'artist': 'Beastie Boys', - 'name': 'Intergalactic' - } - bus.wait_for_response.return_value = Message('test_msg', info) - self.assertEqual(audioservice.track_info(), info) - bus.wait_for_response.return_value = None - self.assertEqual(audioservice.track_info(), {}) - - def test_is_playing(self): - """Test is_playing property.""" - bus = mock.Mock(name='bus') - audioservice = AudioService(bus) - audioservice.track_info = mock.Mock() - - audioservice.track_info.return_value = {'track': 'one cool song'} - self.assertTrue(audioservice.is_playing) - audioservice.track_info.return_value = {} - self.assertFalse(audioservice.is_playing) diff --git a/test/integrationtests/test_event_container.py b/test/integrationtests/test_event_container.py deleted file mode 100644 index 8874eb5b7abd..000000000000 --- a/test/integrationtests/test_event_container.py +++ /dev/null @@ -1,68 +0,0 @@ -import unittest -from unittest import mock -from ovos_utils.events import EventContainer - - -def example_handler(message): - pass - -# TODO - move to ovos-utils -class TestEventContainer(unittest.TestCase): - def test_init(self): - bus = mock.MagicMock() - - # Set bus via init - container = EventContainer(bus) - self.assertEqual(container.bus, bus) - - # Set bus using .set_bus - container = EventContainer(None) - self.assertIsNotNone(container.bus) - container.set_bus(bus) - self.assertEqual(container.bus, bus) - - def test_add(self): - bus = mock.MagicMock() - container = EventContainer(bus) - self.assertEqual(len(container.events), 0) - - # Test add normal event handler - container.add('test1', example_handler) - self.assertTrue(bus.on.called) - - # Test add single shot event handler - len_before = len(container.events) - container.add('test2', example_handler, once=True) - self.assertEqual(len_before + 1, len(container.events)) - self.assertTrue(bus.once.called) - - # Verify correct content in event container - self.assertTrue(('test1', example_handler) in container.events) - self.assertEqual(len(container.events), 2) - - def test_remove(self): - bus = mock.MagicMock() - container = EventContainer(bus) - self.assertEqual(len(container.events), 0) - - container.add('test1', example_handler) - container.add('test2', example_handler) - container.add('test3', example_handler) - self.assertEqual(len(container.events), 3) - - self.assertTrue(('test2', example_handler) in container.events) - container.remove('test2') - self.assertTrue(('test2', example_handler) not in container.events) - self.assertTrue(bus.remove_all_listeners.called) - - def test_clear(self): - bus = mock.MagicMock() - container = EventContainer(bus) - - container.add('test1', example_handler) - container.add('test2', example_handler) - container.add('test3', example_handler) - self.assertEqual(len(container.events), 3) - - container.clear() - self.assertEqual(len(container.events), 0) diff --git a/test/integrationtests/test_event_scheduler.py b/test/integrationtests/test_event_scheduler.py deleted file mode 100644 index 8c2680363c34..000000000000 --- a/test/integrationtests/test_event_scheduler.py +++ /dev/null @@ -1,124 +0,0 @@ -""" - Test cases regarding the event scheduler. -""" - -import unittest -import time -from pyee import ExecutorEventEmitter - -from unittest.mock import MagicMock, patch -from ovos_utils.messagebus import FakeBus -from ovos_bus_client.util.scheduler import EventScheduler, EventSchedulerInterface - - -# TODO - move to ovos-bus-client -class TestEventScheduler(unittest.TestCase): - @patch('threading.Thread') - @patch('json.load') - @patch('json.dump') - @patch('builtins.open') - def test_create(self, mock_open, mock_json_dump, mock_load, mock_thread): - """ - Test creating and shutting down event_scheduler. - """ - mock_load.return_value = '' - mock_open.return_value = MagicMock() - emitter = MagicMock() - es = EventScheduler(emitter) - es.shutdown() - self.assertEqual(mock_json_dump.call_args[0][0], {}) - - @patch('threading.Thread') - @patch('json.load') - @patch('json.dump') - @patch('builtins.open') - def test_add_remove(self, mock_open, mock_json_dump, - mock_load, mock_thread): - """ - Test add an event and then remove it. - """ - # Thread start is mocked so will not actually run the thread loop - mock_load.return_value = '' - mock_open.return_value = MagicMock() - emitter = MagicMock() - es = EventScheduler(emitter) - - # 900000000000 should be in the future for a long time - es.schedule_event('test', 90000000000, None) - es.schedule_event('test-2', 90000000000, None) - - es.check_state() # run one cycle - self.assertTrue('test' in es.events) - self.assertTrue('test-2' in es.events) - - es.remove_event('test') - es.check_state() # run one cycle - self.assertTrue('test' not in es.events) - self.assertTrue('test-2' in es.events) - es.shutdown() - - @patch('threading.Thread') - @patch('json.load') - @patch('json.dump') - @patch('builtins.open') - def test_save(self, mock_open, mock_dump, mock_load, mock_thread): - """ - Test save functionality. - """ - mock_load.return_value = '' - mock_open.return_value = MagicMock() - emitter = MagicMock() - es = EventScheduler(emitter) - - # 900000000000 should be in the future for a long time - es.schedule_event('test', 900000000000, None) - es.schedule_event('test-repeat', 910000000000, 60) - es.check_state() - - es.shutdown() - - # Make sure the dump method wasn't called with test-repeat - self.assertEqual(mock_dump.call_args[0][0], - {'test': [(900000000000, None, {}, None)]}) - - @patch('threading.Thread') - @patch('json.load') - @patch('json.dump') - @patch('builtins.open') - def test_send_event(self, mock_open, mock_dump, mock_load, mock_thread): - """ - Test save functionality. - """ - mock_load.return_value = '' - mock_open.return_value = MagicMock() - emitter = MagicMock() - es = EventScheduler(emitter) - - # 0 should be in the future for a long time - es.schedule_event('test', time.time(), None) - - es.check_state() - self.assertEqual(emitter.emit.call_args[0][0].msg_type, 'test') - self.assertEqual(emitter.emit.call_args[0][0].data, {}) - es.shutdown() - - -class TestEventSchedulerInterface(unittest.TestCase): - def test_shutdown(self): - def f(message): - print('TEST FUNC') - - bus = ExecutorEventEmitter() - - es = EventSchedulerInterface('tester') - es.set_bus(FakeBus()) - es.set_id('id') - - # Schedule a repeating event - es.schedule_repeating_event(f, None, 10, name='f') - self.assertTrue(len(es.bus.ee._events['id:f']) == 1) - - es.shutdown() - # Check that the reference to the function has been removed from the - # bus emitter - self.assertTrue(len(bus._events['id:f']) == 0) diff --git a/test/integrationtests/test_lock.py b/test/integrationtests/test_lock.py deleted file mode 100644 index 2816ce1e1432..000000000000 --- a/test/integrationtests/test_lock.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright 2017 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import signal -import unittest -from shutil import rmtree - -from unittest.mock import patch -import os -from os.path import exists, isfile - -from ovos_utils.process_utils import PIDLock as Lock -from ovos_utils.file_utils import get_temp_path -from ovos_config.meta import get_xdg_base - - -class TestLock(unittest.TestCase): - def setUp(self): - if exists(get_temp_path(get_xdg_base())): - rmtree(get_temp_path(get_xdg_base())) - - def test_create_lock(self): - l1 = Lock('test') - self.assertTrue( - isfile(get_temp_path(get_xdg_base(), 'test.pid'))) - - def test_delete_lock(self): - l1 = Lock('test') - self.assertTrue( - isfile(get_temp_path(get_xdg_base(), 'test.pid'))) - l1.delete() - self.assertFalse( - isfile(get_temp_path(get_xdg_base(), 'test.pid'))) - - @patch('os.kill') - def test_existing_lock(self, mock_kill): - """ Test that an existing lock will kill the old pid. """ - l1 = Lock('test') - self.assertTrue( - isfile(get_temp_path(get_xdg_base(), 'test.pid'))) - l2 = Lock('test2') - self.assertFalse(mock_kill.called) - l2 = Lock('test') - self.assertTrue(mock_kill.called) - - def test_keyboard_interrupt(self): - l1 = Lock('test') - self.assertTrue( - isfile(get_temp_path(get_xdg_base(), 'test.pid'))) - try: - os.kill(os.getpid(), signal.SIGINT) - except KeyboardInterrupt: - pass - self.assertFalse( - isfile(get_temp_path(get_xdg_base(), 'test.pid'))) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/integrationtests/test_selene_api.py b/test/integrationtests/test_selene_api.py index f063af1a2b0e..79641b30b447 100644 --- a/test/integrationtests/test_selene_api.py +++ b/test/integrationtests/test_selene_api.py @@ -19,6 +19,8 @@ import ovos_backend_client.pairing from unittest.mock import MagicMock, patch +# TODO - move test to ovos-backend.client + ovos_backend_client.backends.base.requests.post = MagicMock() diff --git a/test/integrationtests/test_workshop.py b/test/integrationtests/test_workshop.py index fc5e469497aa..b3840093ce6c 100644 --- a/test/integrationtests/test_workshop.py +++ b/test/integrationtests/test_workshop.py @@ -2,8 +2,7 @@ import unittest from os.path import dirname from time import sleep -from mycroft.skills.skill_loader import SkillLoader -from mycroft.skills.mycroft_skill.mycroft_skill import MycroftSkill +from ovos_workshop.skill_launcher import SkillLoader from ovos_workshop.skills.ovos import OVOSSkill from ovos_utils.messagebus import FakeBus, Message @@ -29,7 +28,6 @@ def get_msg(msg): def test_skill_id(self): self.assertTrue(isinstance(self.skill.instance, OVOSSkill)) - self.assertTrue(isinstance(self.skill.instance, MycroftSkill)) self.assertEqual(self.skill.skill_id, "abort.test") # if running in ovos-core every message will have the skill_id in context diff --git a/test/integrationtests/translate/in-dialog/dialog/en-us/good_things.list b/test/integrationtests/translate/in-dialog/dialog/en-us/good_things.list deleted file mode 100644 index 78a4efa0eb0d..000000000000 --- a/test/integrationtests/translate/in-dialog/dialog/en-us/good_things.list +++ /dev/null @@ -1,3 +0,0 @@ -sunshine -mycroft -licorice diff --git a/test/integrationtests/translate/in-dialog/dialog/en-us/named_things.value b/test/integrationtests/translate/in-dialog/dialog/en-us/named_things.value deleted file mode 100644 index 5e44c5cc065d..000000000000 --- a/test/integrationtests/translate/in-dialog/dialog/en-us/named_things.value +++ /dev/null @@ -1,4 +0,0 @@ -dot,0 -line,1 -circle,2 -ball,3 diff --git a/test/integrationtests/translate/in-dialog/dialog/en-us/test.template b/test/integrationtests/translate/in-dialog/dialog/en-us/test.template deleted file mode 100644 index 8a6a6b8477c5..000000000000 --- a/test/integrationtests/translate/in-dialog/dialog/en-us/test.template +++ /dev/null @@ -1 +0,0 @@ -Oh look it's my favourite {thing} diff --git a/test/integrationtests/translate/in-locale/locale/de-de/good_things.list b/test/integrationtests/translate/in-locale/locale/de-de/good_things.list deleted file mode 100644 index 1ca068048fbd..000000000000 --- a/test/integrationtests/translate/in-locale/locale/de-de/good_things.list +++ /dev/null @@ -1,3 +0,0 @@ -sonne -mycroft -zahne diff --git a/test/integrationtests/translate/in-locale/locale/de-de/named_things.value b/test/integrationtests/translate/in-locale/locale/de-de/named_things.value deleted file mode 100644 index 3d7ac3247568..000000000000 --- a/test/integrationtests/translate/in-locale/locale/de-de/named_things.value +++ /dev/null @@ -1,3 +0,0 @@ -gelb,0 -rot,1 -blau,2 diff --git a/test/integrationtests/translate/in-locale/locale/de-de/test.template b/test/integrationtests/translate/in-locale/locale/de-de/test.template deleted file mode 100644 index c7d26b08efac..000000000000 --- a/test/integrationtests/translate/in-locale/locale/de-de/test.template +++ /dev/null @@ -1 +0,0 @@ -Aber setzen sie sich herr {thing} diff --git a/test/integrationtests/translate/in-locale/locale/en-us/good_things.list b/test/integrationtests/translate/in-locale/locale/en-us/good_things.list deleted file mode 100644 index 78a4efa0eb0d..000000000000 --- a/test/integrationtests/translate/in-locale/locale/en-us/good_things.list +++ /dev/null @@ -1,3 +0,0 @@ -sunshine -mycroft -licorice diff --git a/test/integrationtests/translate/in-locale/locale/en-us/named_things.value b/test/integrationtests/translate/in-locale/locale/en-us/named_things.value deleted file mode 100644 index 5e44c5cc065d..000000000000 --- a/test/integrationtests/translate/in-locale/locale/en-us/named_things.value +++ /dev/null @@ -1,4 +0,0 @@ -dot,0 -line,1 -circle,2 -ball,3 diff --git a/test/integrationtests/translate/in-locale/locale/en-us/not_in_german.list b/test/integrationtests/translate/in-locale/locale/en-us/not_in_german.list deleted file mode 100644 index 5755f36c6661..000000000000 --- a/test/integrationtests/translate/in-locale/locale/en-us/not_in_german.list +++ /dev/null @@ -1,3 +0,0 @@ -not -in -German diff --git a/test/integrationtests/translate/in-locale/locale/en-us/test.template b/test/integrationtests/translate/in-locale/locale/en-us/test.template deleted file mode 100644 index 8a6a6b8477c5..000000000000 --- a/test/integrationtests/translate/in-locale/locale/en-us/test.template +++ /dev/null @@ -1 +0,0 @@ -Oh look it's my favourite {thing} diff --git a/test/integrationtests/util/__init__.py b/test/integrationtests/util/__init__.py deleted file mode 100644 index 051afedb75cd..000000000000 --- a/test/integrationtests/util/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# TODO - move to ovos-utils diff --git a/test/integrationtests/util/commented.json b/test/integrationtests/util/commented.json deleted file mode 100644 index 00a581f6df47..000000000000 --- a/test/integrationtests/util/commented.json +++ /dev/null @@ -1,168 +0,0 @@ -// Leading comment - -{ -// C-style comment - "lang": "en-us", - - // Comment spaced out - "system_unit": "metric", - - // Comment tabbed out - - "time_format": "half", - - // comment and // another inside - "date_format": "MDY", - - // Comment with " inside it - "confirm_listening": true, - - # Python-style comment - "sounds": { -# Commment with no space - "start_listening": "snd/start_listening.wav", - # Comment inside with a tab - # and multiple lines - "end_listening": "snd/end_listening.wav" - // and a final thought - }, - "play_wav_cmdline": "aplay %1", - "play_mp3_cmdline": "mpg123 %1", - "play_ogg_cmdline": "ogg123 %1", - "location": { - "city": { - "code": "Lawrence", - "name": "Lawrence", - "state": { - "code": "KS", - "name": "Kansas", - "country": { - "code": "US", - "name": "United States" - } - } - }, - "coordinate": { - "latitude": 38.971669, - "longitude": -95.23525 - }, - "timezone": { - "code": "America/Chicago", - "name": "Central Standard Time", - "dstOffset": 3600000, - "offset": -21600000 - } - }, - "skills": { - "directory": "~/.local/share/mycroft/skills" - }, - "server": { - "url": "https://api.mycroft.ai", - "version": "v1", - "update": true, - "metrics": false - }, - "websocket": { - "host": "0.0.0.0", - "port": 8181, - "route": "/core", - "ssl": false - }, - "listener": { - "sample_rate": 16000, - "channels": 1, - "wake_word": "hey mycroft", - "phonemes": "HH EY . M AY K R AO F T", - "threshold": 1e-90, - "multiplier": 1.0, - "energy_ratio": 1.5 - }, - "enclosure": { - "port": "/dev/ttyAMA0", - "rate": 9600, - "timeout": 5.0, - "update": true, - "test": false - }, - "log_level": "DEBUG", - "ignore_logs": ["enclosure.mouth.viseme"], - "session": { - "ttl": 180 - }, - "stt": { - "module": "mycroft" - }, - "tts": { - "module": "mimic", - "mimic": { - "voice": "ap" - }, - "espeak": { - "lang": "english-us", - "voice": "m1" - } - }, - - // Mixture - # of types - // of comments - - - "wifi": { - "setup": false - }, - "ConfigurationSkill": { - "max_delay": 60 - }, - "WikipediaSkill": { - "max_results": 5, - "max_phrases": 2 - }, - "WolframAlphaSkill": { - "api_key": "", - "proxy": true - }, - "WeatherSkill": { - "api_key": "", - "proxy": true, - "temperature": "fahrenheit" - }, - "NPRNewsSkill": { - "url_rss": "http://www.npr.org/rss/podcast.php?id=500005" - }, - "AlarmSkill": { - "filename": "alarm.mp3", - "max_delay": 600, - "repeat_time": 20, - "extended_delay": 60 - }, - "ReminderSkill": { - "max_delay": 600, - "repeat_time": 60, - "extended_delay": 60 - }, - "VolumeSkill": { - "default_level": 6, - "min_volume": 0, - "max_volume": 100 - }, - "AudioRecordSkill": { - "filename": "/tmp/mycroft-recording.wav", - "free_disk": 100, - "max_time": 600, - "notify_delay": 5, - "rate": 16000, - "channels": 1 - }, - "SkillInstallerSkill": { - } -} - - - - - -# Trailing comments -# These go on -# and on - // and on diff --git a/test/integrationtests/util/muppets.dict b/test/integrationtests/util/muppets.dict deleted file mode 100644 index dc736bc4c9e2..000000000000 --- a/test/integrationtests/util/muppets.dict +++ /dev/null @@ -1,2 +0,0 @@ -muppet = miss piggy -fraggle = gobo diff --git a/test/integrationtests/util/plain.json b/test/integrationtests/util/plain.json deleted file mode 100644 index eec84631d886..000000000000 --- a/test/integrationtests/util/plain.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "lang": "en-us", - "system_unit": "metric", - "time_format": "half", - "date_format": "MDY", - "confirm_listening": true, - "sounds": { - "start_listening": "snd/start_listening.wav", - "end_listening": "snd/end_listening.wav" - }, - "play_wav_cmdline": "aplay %1", - "play_mp3_cmdline": "mpg123 %1", - "play_ogg_cmdline": "ogg123 %1", - "location": { - "city": { - "code": "Lawrence", - "name": "Lawrence", - "state": { - "code": "KS", - "name": "Kansas", - "country": { - "code": "US", - "name": "United States" - } - } - }, - "coordinate": { - "latitude": 38.971669, - "longitude": -95.23525 - }, - "timezone": { - "code": "America/Chicago", - "name": "Central Standard Time", - "dstOffset": 3600000, - "offset": -21600000 - } - }, - "skills": { - "directory": "~/.local/share/mycroft/skills" - }, - "server": { - "url": "https://api.mycroft.ai", - "version": "v1", - "update": true, - "metrics": false - }, - "websocket": { - "host": "0.0.0.0", - "port": 8181, - "route": "/core", - "ssl": false - }, - "listener": { - "sample_rate": 16000, - "channels": 1, - "wake_word": "hey mycroft", - "phonemes": "HH EY . M AY K R AO F T", - "threshold": 1e-90, - "multiplier": 1.0, - "energy_ratio": 1.5 - }, - "enclosure": { - "port": "/dev/ttyAMA0", - "rate": 9600, - "timeout": 5.0, - "update": true, - "test": false - }, - "log_level": "DEBUG", - "ignore_logs": ["enclosure.mouth.viseme"], - "session": { - "ttl": 180 - }, - "stt": { - "module": "mycroft" - }, - "tts": { - "module": "mimic", - "mimic": { - "voice": "ap" - }, - "espeak": { - "lang": "english-us", - "voice": "m1" - } - }, - "wifi": { - "setup": false - }, - "ConfigurationSkill": { - "max_delay": 60 - }, - "WikipediaSkill": { - "max_results": 5, - "max_phrases": 2 - }, - "WolframAlphaSkill": { - "api_key": "", - "proxy": true - }, - "WeatherSkill": { - "api_key": "", - "proxy": true, - "temperature": "fahrenheit" - }, - "NPRNewsSkill": { - "url_rss": "http://www.npr.org/rss/podcast.php?id=500005" - }, - "AlarmSkill": { - "filename": "alarm.mp3", - "max_delay": 600, - "repeat_time": 20, - "extended_delay": 60 - }, - "ReminderSkill": { - "max_delay": 600, - "repeat_time": 60, - "extended_delay": 60 - }, - "VolumeSkill": { - "default_level": 6, - "min_volume": 0, - "max_volume": 100 - }, - "AudioRecordSkill": { - "filename": "/tmp/mycroft-recording.wav", - "free_disk": 100, - "max_time": 600, - "notify_delay": 5, - "rate": 16000, - "channels": 1 - }, - "SkillInstallerSkill": { - } -} diff --git a/test/integrationtests/util/test_audio_utils.py b/test/integrationtests/util/test_audio_utils.py deleted file mode 100644 index 626b0f5a0574..000000000000 --- a/test/integrationtests/util/test_audio_utils.py +++ /dev/null @@ -1,138 +0,0 @@ - -from unittest import TestCase, mock - -from mycroft.util import (play_ogg, play_mp3, play_wav, play_audio_file) - -class Anything: - """Class matching any object. - - Useful for assert_called_with arguments. - """ - def __eq__(self, other): - return True - - -test_config = { - 'play_wav_cmdline': 'mock_wav %1', - 'play_mp3_cmdline': 'mock_mp3 %1', - 'play_ogg_cmdline': 'mock_ogg %1' -} - - -@mock.patch('ovos_utils.sound.read_mycroft_config') -@mock.patch('ovos_utils.sound.subprocess') -class TestPlaySounds(TestCase): - def test_play_ogg(self, mock_subprocess, mock_conf): - mock_conf.return_value = test_config - play_ogg('insult.ogg') - mock_subprocess.Popen.assert_called_once_with(['mock_ogg', - 'insult.ogg'], - env=Anything()) - - @mock.patch('ovos_utils.sound.LOG') - def test_play_ogg_file_not_found(self, mock_log, - mock_subprocess, mock_conf): - """Test that simple log is raised when subprocess can't find command. - """ - def raise_filenotfound(*arg, **kwarg): - raise FileNotFoundError('TEST FILE NOT FOUND') - - mock_subprocess.Popen.side_effect = raise_filenotfound - mock_conf.return_value = test_config - self.assertEqual(play_ogg('insult.ogg'), None) - mock_log.error.called_once_with(Anything()) - - @mock.patch('ovos_utils.sound.LOG') - def test_play_ogg_exception(self, mock_log, - mock_subprocess, mock_conf): - """Test that stack trace is provided when unknown excpetion occurs""" - def raise_exception(*arg, **kwarg): - raise Exception - - mock_subprocess.Popen.side_effect = raise_exception - mock_conf.return_value = test_config - self.assertEqual(play_ogg('insult.ogg'), None) - mock_log.exception.called_once_with(Anything()) - - def test_play_mp3(self, mock_subprocess, mock_conf): - mock_conf.return_value = test_config - play_mp3('praise.mp3') - mock_subprocess.Popen.assert_called_once_with(['mock_mp3', - 'praise.mp3'], - env=Anything()) - - @mock.patch('ovos_utils.sound.LOG') - def test_play_mp3_file_not_found(self, mock_log, - mock_subprocess, mock_conf): - """Test that simple log is raised when subprocess can't find command. - """ - def raise_filenotfound(*arg, **kwarg): - raise FileNotFoundError('TEST FILE NOT FOUND') - - mock_subprocess.Popen.side_effect = raise_filenotfound - mock_conf.return_value = test_config - self.assertEqual(play_mp3('praise.mp3'), None) - mock_log.error.called_once_with(Anything()) - - @mock.patch('ovos_utils.sound.LOG') - def test_play_mp3_exception(self, mock_log, - mock_subprocess, mock_conf): - """Test that stack trace is provided when unknown excpetion occurs""" - def raise_exception(*arg, **kwarg): - raise Exception - - mock_subprocess.Popen.side_effect = raise_exception - mock_conf.return_value = test_config - self.assertEqual(play_mp3('praise.mp3'), None) - mock_log.exception.called_once_with(Anything()) - - def test_play_wav(self, mock_subprocess, mock_conf): - mock_conf.return_value = test_config - play_wav('indifference.wav') - mock_subprocess.Popen.assert_called_once_with(['mock_wav', - 'indifference.wav'], - env=Anything()) - - @mock.patch('ovos_utils.sound.LOG') - def test_play_wav_file_not_found(self, mock_log, - mock_subprocess, mock_conf): - """Test that simple log is raised when subprocess can't find command. - """ - def raise_filenotfound(*arg, **kwarg): - raise FileNotFoundError('TEST FILE NOT FOUND') - - mock_subprocess.Popen.side_effect = raise_filenotfound - mock_conf.return_value = test_config - self.assertEqual(play_wav('indifference.wav'), None) - mock_log.error.called_once_with(Anything()) - - @mock.patch('ovos_utils.sound.LOG') - def test_play_wav_exception(self, mock_log, - mock_subprocess, mock_conf): - """Test that stack trace is provided when unknown excpetion occurs""" - def raise_exception(*arg, **kwarg): - raise Exception - - mock_subprocess.Popen.side_effect = raise_exception - mock_conf.return_value = test_config - self.assertEqual(play_wav('indifference.wav'), None) - mock_log.exception.called_once_with(Anything()) - - def test_play_audio_file(self, mock_subprocess, mock_conf): - mock_conf.return_value = test_config - play_audio_file('indifference.wav') - mock_subprocess.Popen.assert_called_once_with(['mock_wav', - 'indifference.wav'], - env=Anything()) - mock_subprocess.Popen.reset_mock() - - play_audio_file('praise.mp3') - mock_subprocess.Popen.assert_called_once_with(['mock_mp3', - 'praise.mp3'], - env=Anything()) - mock_subprocess.Popen.reset_mock() - mock_conf.return_value = test_config - play_audio_file('insult.ogg') - mock_subprocess.Popen.assert_called_once_with(['mock_ogg', - 'insult.ogg'], - env=Anything()) diff --git a/test/integrationtests/util/test_download.py b/test/integrationtests/util/test_download.py deleted file mode 100644 index 7b11dbb5d455..000000000000 --- a/test/integrationtests/util/test_download.py +++ /dev/null @@ -1,109 +0,0 @@ - -from threading import Event -from unittest import TestCase, mock - -from mycroft.util.download import (download, _running_downloads, - _get_download_tmp) -from mycroft.util.file_utils import get_temp_path - -TEST_URL = 'http://example.com/mycroft-test.tar.gz' -TEST_DEST = get_temp_path('file.tar.gz') - - -@mock.patch('mycroft.util.download.subprocess') -@mock.patch('mycroft.util.download.os') -class TestDownload(TestCase): - def setUp(self): - """Remove any cached instance.""" - for key in list(_running_downloads.keys()): - _running_downloads.pop(key) - - def test_download_basic(self, mock_os, mock_subprocess): - """Test the basic download call.""" - mock_subprocess.call.return_value = 0 - - downloader = download(url=TEST_URL, - dest=TEST_DEST) - downloader.join() - mock_subprocess.call.assert_called_once_with(['wget', '-c', TEST_URL, - '-O', - TEST_DEST + '.part', - '--tries=20', - '--read-timeout=5']) - self.assertTrue(downloader.done) - - def test_download_with_header(self, mock_os, mock_subprocess): - """Test download with specific header.""" - mock_subprocess.call.return_value = 0 - - test_hdr = 'TEST_HEADER' - downloader = download(url=TEST_URL, - dest=TEST_DEST, - header=test_hdr) - downloader.join() - - self.assertTrue(downloader.done) - mock_subprocess.call.assert_called_once_with(['wget', '-c', TEST_URL, - '-O', - TEST_DEST + '.part', - '--tries=20', - '--read-timeout=5', - '--header=' + test_hdr]) - - def test_download_callback(self, mock_os, mock_subprocess): - """Check that callback function is called with correct destination.""" - mock_subprocess.call.return_value = 0 - action_called_with = None - - def action(dest): - nonlocal action_called_with - action_called_with = dest - - downloader = download(url=TEST_URL, - dest=TEST_DEST, - complete_action=action) - downloader.join() - - self.assertTrue(downloader.done) - self.assertEqual(action_called_with, TEST_DEST) - - def test_download_cache(self, mock_os, mock_subprocess): - """Make sure that a cached download is used if exists.""" - - transfer_done = Event() - - def wget_call(*args, **kwargs): - nonlocal transfer_done - transfer_done.wait() - return 0 - - downloader = download(url=TEST_URL, - dest=TEST_DEST) - downloader2 = download(url=TEST_URL, - dest=TEST_DEST) - # When called with the same args a cached download in progress should - # be returned instead of a new one. - self.assertTrue(downloader is downloader2) - transfer_done.set() - downloader.join() - - -@mock.patch('mycroft.util.download.glob') -class TestGetTemp(TestCase): - def test_no_existing(self, mock_glob): - mock_glob.return_value = [] - dest = get_temp_path('test') - self.assertEqual(_get_download_tmp(dest), dest + '.part') - - def test_existing(self, mock_glob): - mock_glob.return_value = [get_temp_path('test.part')] - dest = get_temp_path('test') - self.assertEqual(_get_download_tmp(dest), dest + '.part.1') - - def test_multiple_existing(self, mock_glob): - mock_glob.return_value = [get_temp_path('test.part'), - get_temp_path('test.part.1'), - get_temp_path('test.part.2')] - - dest = get_temp_path('test') - self.assertEqual(_get_download_tmp(dest), dest + '.part.3') diff --git a/test/integrationtests/util/test_json_helper.py b/test/integrationtests/util/test_json_helper.py deleted file mode 100644 index 76b31e28eead..000000000000 --- a/test/integrationtests/util/test_json_helper.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2017 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import json -import unittest - -from os.path import dirname, join - -from mycroft.util.json_helper import load_commented_json - - -class TestFileLoad(unittest.TestCase): - - def test_load(self): - root_dir = dirname(__file__) - # Load normal JSON file - plainfile = join(root_dir, 'plain.json') - with open(plainfile, 'r') as f: - data_from_plain = json.load(f) - - # Load commented JSON file - commentedfile = join(root_dir, 'commented.json') - data_from_commented = load_commented_json(commentedfile) - - # Should be the same... - self.assertEqual(data_from_commented, data_from_plain) - - -if __name__ == "__main__": - unittest.main() diff --git a/test/integrationtests/util/test_log.py b/test/integrationtests/util/test_log.py deleted file mode 100644 index 42390f965ebc..000000000000 --- a/test/integrationtests/util/test_log.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2017 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import unittest -import sys -from io import StringIO -from threading import Thread -from mycroft.util.log import LOG - - -class CaptureLogs(list): - def __init__(self): - list.__init__(self) - self._stdout = None - self._stringio = None - - def __enter__(self): - self._stdout = sys.stdout - sys.stdout = self._stringio = StringIO() - LOG.init() - return self - - def __exit__(self, *args): - self.extend(self._stringio.getvalue().splitlines()) - del self._stringio # free up some memory - sys.stdout = self._stdout - LOG.init() - - -class TestLog(unittest.TestCase): - def test_threads(self): - with CaptureLogs() as output: - def test_logging(): - LOG.debug('testing debug') - LOG.info('testing info') - LOG.warning('testing warning') - LOG.error('testing error') - LOG('testing custom').debug('test') - - threads = [] - for _ in range(100): - t = Thread(target=test_logging) - t.start() - threads.append(t) - - for t in threads: - t.join() - - assert len(output) > 0 - - for line in output: - found_msg = False - for msg in ['debug', 'info', 'warning', 'error', 'custom']: - if 'testing ' + msg in line: - found_msg = True - assert found_msg - - -if __name__ == "__main__": - unittest.main() diff --git a/test/integrationtests/util/test_monotonic_event.py b/test/integrationtests/util/test_monotonic_event.py deleted file mode 100644 index 9c7d27770e01..000000000000 --- a/test/integrationtests/util/test_monotonic_event.py +++ /dev/null @@ -1,32 +0,0 @@ -from threading import Thread -from time import sleep -from unittest import TestCase, mock - -from mycroft.util.monotonic_event import MonotonicEvent - - -class MonotonicEventTest(TestCase): - def test_wait_set(self): - event = MonotonicEvent() - event.set() - self.assertTrue(event.wait()) - - def test_wait_timeout(self): - event = MonotonicEvent() - self.assertFalse(event.wait(0.1)) - - def test_wait_set_with_timeout(self): - wait_result = False - event = MonotonicEvent() - - def wait_event(): - nonlocal wait_result - wait_result = event.wait(30) - - wait_thread = Thread(target=wait_event) - wait_thread.start() - - sleep(0.1) - event.set() - wait_thread.join() - self.assertTrue(wait_result) diff --git a/test/integrationtests/util/test_network_utils.py b/test/integrationtests/util/test_network_utils.py deleted file mode 100644 index ed7dcc1653be..000000000000 --- a/test/integrationtests/util/test_network_utils.py +++ /dev/null @@ -1,52 +0,0 @@ -from unittest import TestCase, mock - -from mycroft.util.network_utils import connected - - -class TestNetworkConnected(TestCase): - def test_default_config_succeeds(self): - """Check that happy path succeeds""" - self.assertTrue(connected()) - - -@mock.patch('ovos_config.config.Configuration') -class TestNetworkFailure(TestCase): - - def test_dns_and_ncsi_fail(self, mock_conf): - """Check that DNS and NCSI failure results in False response""" - mock_conf.return_value = { - "network_tests": { - "dns_primary": "127.0.0.1", - "dns_secondary": "127.0.0.1", - "web_url": "https://www.google.com", - "ncsi_endpoint": "http://www.msftncsi.com/ncsi.txt", - "ncsi_expected_text": "Unexpected text" - } - } - self.assertFalse(connected()) - - def test_secondary_dns_succeeds(self, mock_conf): - """Check that only primary DNS failing still succeeds""" - mock_conf.return_value = { - "network_tests": { - "dns_primary": "127.0.0.1", - "dns_secondary": "8.8.4.4", - "web_url": "https://www.google.com", - "ncsi_endpoint": "http://www.msftncsi.com/ncsi.txt", - "ncsi_expected_text": "Microsoft NCSI" - } - } - self.assertTrue(connected()) - - def test_dns_success_url_fail(self, mock_conf): - """Check that URL connection failure results in False response""" - mock_conf.return_value = { - "network_tests": { - "dns_primary": "8.8.8.8", - "dns_secondary": "8.8.4.4", - "web_url": "https://test.invalid", - "ncsi_endpoint": "http://www.msftncsi.com/ncsi.txt", - "ncsi_expected_text": "Microsoft NCSI" - } - } - self.assertFalse(connected()) diff --git a/test/integrationtests/util/test_parse.py b/test/integrationtests/util/test_parse.py deleted file mode 100644 index 6711a42120db..000000000000 --- a/test/integrationtests/util/test_parse.py +++ /dev/null @@ -1,263 +0,0 @@ -# -# Copyright 2017 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import unittest -from datetime import datetime, timedelta - -from mycroft.configuration.locale import load_language, get_default_tz -from lingua_franca.internal import FunctionNotLocalizedError - -from mycroft.util.parse import ( - extract_datetime, - extract_duration, - extract_number, - extract_numbers, - fuzzy_match, - get_gender, - match_one, - normalize -) -from mycroft.util.time import default_timezone - - -load_language("en-us") - - -class TestFuzzyMatch(unittest.TestCase): - def test_matches(self): - self.assertTrue(fuzzy_match("you and me", "you and me") >= 1.0) - self.assertTrue(fuzzy_match("you and me", "you") < 0.5) - self.assertTrue(fuzzy_match("You", "you") > 0.5) - self.assertTrue(fuzzy_match("you and me", "you") == - fuzzy_match("you", "you and me")) - self.assertTrue(fuzzy_match("you and me", "he or they") < 0.2) - - def test_match_one(self): - # test list of choices - choices = ['frank', 'kate', 'harry', 'henry'] - self.assertEqual(match_one('frank', choices)[0], 'frank') - self.assertEqual(match_one('fran', choices)[0], 'frank') - self.assertEqual(match_one('enry', choices)[0], 'henry') - self.assertEqual(match_one('katt', choices)[0], 'kate') - # test dictionary of choices - choices = {'frank': 1, 'kate': 2, 'harry': 3, 'henry': 4} - self.assertEqual(match_one('frank', choices)[0], 1) - self.assertEqual(match_one('enry', choices)[0], 4) - - -class TestNormalize(unittest.TestCase): - def test_articles(self): - self.assertEqual(normalize("this is a test", remove_articles=True), - "this is test") - self.assertEqual(normalize("this is the test", remove_articles=True), - "this is test") - self.assertEqual(normalize("and another test", remove_articles=True), - "and another test") - self.assertEqual(normalize("this is an extra test", - remove_articles=False), - "this is an extra test") - - def test_spaces(self): - self.assertEqual(normalize(" this is a test"), - "this is test") - self.assertEqual(normalize(" this is a test "), - "this is test") - self.assertEqual(normalize(" this is one test"), - "this is 1 test") - - def test_numbers(self): - self.assertEqual(normalize("this is a one two three test"), - "this is 1 2 3 test") - self.assertEqual(normalize(" it's a four five six test"), - "it is 4 5 6 test") - self.assertEqual(normalize("it's a seven eight nine test"), - "it is 7 8 9 test") - self.assertEqual(normalize("it's a seven eight nine test"), - "it is 7 8 9 test") - self.assertEqual(normalize("that's a ten eleven twelve test"), - "that is 10 11 12 test") - self.assertEqual(normalize("that's a thirteen fourteen test"), - "that is 13 14 test") - self.assertEqual(normalize("that's fifteen sixteen seventeen"), - "that is 15 16 17") - self.assertEqual(normalize("that's eighteen nineteen twenty"), - "that is 18 19 20") - self.assertEqual(normalize("that's one nineteen twenty two"), - "that is 1 19 22") - self.assertEqual(normalize("that's one hundred"), - "that is 100") - self.assertEqual(normalize("that's one two twenty two"), - "that is 1 2 22") - self.assertEqual(normalize("that's one and a half"), - "that is 1 and half") - self.assertEqual(normalize("that's one and a half and five six"), - "that is 1 and half and 5 6") - - def test_contractions(self): - self.assertEqual(normalize("ain't"), "is not") - self.assertEqual(normalize("aren't"), "are not") - self.assertEqual(normalize("can't"), "can not") - self.assertEqual(normalize("could've"), "could have") - self.assertEqual(normalize("couldn't"), "could not") - self.assertEqual(normalize("didn't"), "did not") - self.assertEqual(normalize("doesn't"), "does not") - self.assertEqual(normalize("don't"), "do not") - self.assertEqual(normalize("gonna"), "going to") - self.assertEqual(normalize("gotta"), "got to") - self.assertEqual(normalize("hadn't"), "had not") - self.assertEqual(normalize("hadn't have"), "had not have") - self.assertEqual(normalize("hasn't"), "has not") - self.assertEqual(normalize("haven't"), "have not") - # TODO: Ambiguous with "he had" - self.assertEqual(normalize("he'd"), "he would") - self.assertEqual(normalize("he'll"), "he will") - # TODO: Ambiguous with "he has" - self.assertEqual(normalize("he's"), "he is") - # TODO: Ambiguous with "how would" - self.assertEqual(normalize("how'd"), "how did") - self.assertEqual(normalize("how'll"), "how will") - # TODO: Ambiguous with "how has" and "how does" - self.assertEqual(normalize("how's"), "how is") - # TODO: Ambiguous with "I had" - self.assertEqual(normalize("I'd"), "I would") - self.assertEqual(normalize("I'll"), "I will") - self.assertEqual(normalize("I'm"), "I am") - self.assertEqual(normalize("I've"), "I have") - self.assertEqual(normalize("I haven't"), "I have not") - self.assertEqual(normalize("isn't"), "is not") - self.assertEqual(normalize("it'd"), "it would") - self.assertEqual(normalize("it'll"), "it will") - # TODO: Ambiguous with "it has" - self.assertEqual(normalize("it's"), "it is") - self.assertEqual(normalize("it isn't"), "it is not") - self.assertEqual(normalize("mightn't"), "might not") - self.assertEqual(normalize("might've"), "might have") - self.assertEqual(normalize("mustn't"), "must not") - self.assertEqual(normalize("mustn't have"), "must not have") - self.assertEqual(normalize("must've"), "must have") - self.assertEqual(normalize("needn't"), "need not") - self.assertEqual(normalize("oughtn't"), "ought not") - self.assertEqual(normalize("shan't"), "shall not") - # TODO: Ambiguous wiht "she had" - self.assertEqual(normalize("she'd"), "she would") - self.assertEqual(normalize("she hadn't"), "she had not") - self.assertEqual(normalize("she'll"), "she will") - self.assertEqual(normalize("she's"), "she is") - self.assertEqual(normalize("she isn't"), "she is not") - self.assertEqual(normalize("should've"), "should have") - self.assertEqual(normalize("shouldn't"), "should not") - self.assertEqual(normalize("shouldn't have"), "should not have") - self.assertEqual(normalize("somebody's"), "somebody is") - # TODO: Ambiguous with "someone had" - self.assertEqual(normalize("someone'd"), "someone would") - self.assertEqual(normalize("someone hadn't"), "someone had not") - self.assertEqual(normalize("someone'll"), "someone will") - # TODO: Ambiguous with "someone has" - self.assertEqual(normalize("someone's"), "someone is") - self.assertEqual(normalize("that'll"), "that will") - # TODO: Ambiguous with "that has" - self.assertEqual(normalize("that's"), "that is") - # TODO: Ambiguous with "that had" - self.assertEqual(normalize("that'd"), "that would") - # TODO: Ambiguous with "there had" - self.assertEqual(normalize("there'd"), "there would") - self.assertEqual(normalize("there're"), "there are") - # TODO: Ambiguous with "there has" - self.assertEqual(normalize("there's"), "there is") - # TODO: Ambiguous with "they had" - self.assertEqual(normalize("they'd"), "they would") - self.assertEqual(normalize("they'll"), "they will") - self.assertEqual(normalize("they won't have"), "they will not have") - self.assertEqual(normalize("they're"), "they are") - self.assertEqual(normalize("they've"), "they have") - self.assertEqual(normalize("they haven't"), "they have not") - self.assertEqual(normalize("wasn't"), "was not") - # TODO: Ambiguous wiht "we had" - self.assertEqual(normalize("we'd"), "we would") - self.assertEqual(normalize("we would've"), "we would have") - self.assertEqual(normalize("we wouldn't"), "we would not") - self.assertEqual(normalize("we wouldn't have"), "we would not have") - self.assertEqual(normalize("we'll"), "we will") - self.assertEqual(normalize("we won't have"), "we will not have") - self.assertEqual(normalize("we're"), "we are") - self.assertEqual(normalize("we've"), "we have") - self.assertEqual(normalize("weren't"), "were not") - self.assertEqual(normalize("what'd"), "what did") - self.assertEqual(normalize("what'll"), "what will") - self.assertEqual(normalize("what're"), "what are") - # TODO: Ambiguous with "what has" / "what does") - self.assertEqual(normalize("whats"), "what is") - self.assertEqual(normalize("what's"), "what is") - self.assertEqual(normalize("what've"), "what have") - # TODO: Ambiguous with "when has" - self.assertEqual(normalize("when's"), "when is") - self.assertEqual(normalize("where'd"), "where did") - # TODO: Ambiguous with "where has" / where does" - self.assertEqual(normalize("where's"), "where is") - self.assertEqual(normalize("where've"), "where have") - # TODO: Ambiguous with "who had" "who did") - self.assertEqual(normalize("who'd"), "who would") - self.assertEqual(normalize("who'd've"), "who would have") - self.assertEqual(normalize("who'll"), "who will") - self.assertEqual(normalize("who're"), "who are") - # TODO: Ambiguous with "who has" / "who does" - self.assertEqual(normalize("who's"), "who is") - self.assertEqual(normalize("who've"), "who have") - self.assertEqual(normalize("why'd"), "why did") - self.assertEqual(normalize("why're"), "why are") - # TODO: Ambiguous with "why has" / "why does" - self.assertEqual(normalize("why's"), "why is") - self.assertEqual(normalize("won't"), "will not") - self.assertEqual(normalize("won't've"), "will not have") - self.assertEqual(normalize("would've"), "would have") - self.assertEqual(normalize("wouldn't"), "would not") - self.assertEqual(normalize("wouldn't've"), "would not have") - self.assertEqual(normalize("ya'll"), "you all") - self.assertEqual(normalize("y'all"), "you all") - self.assertEqual(normalize("y'ain't"), "you are not") - # TODO: Ambiguous with "you had" - self.assertEqual(normalize("you'd"), "you would") - self.assertEqual(normalize("you'd've"), "you would have") - self.assertEqual(normalize("you'll"), "you will") - self.assertEqual(normalize("you're"), "you are") - self.assertEqual(normalize("you aren't"), "you are not") - self.assertEqual(normalize("you've"), "you have") - self.assertEqual(normalize("you haven't"), "you have not") - - def test_combinations(self): - self.assertEqual(normalize("I couldn't have guessed there'd be two"), - "I could not have guessed there would be 2") - self.assertEqual(normalize("I wouldn't have"), "I would not have") - self.assertEqual(normalize("I hadn't been there"), - "I had not been there") - self.assertEqual(normalize("I would've"), "I would have") - self.assertEqual(normalize("it hadn't"), "it had not") - self.assertEqual(normalize("it hadn't have"), "it had not have") - self.assertEqual(normalize("it would've"), "it would have") - self.assertEqual(normalize("she wouldn't have"), "she would not have") - self.assertEqual(normalize("she would've"), "she would have") - self.assertEqual(normalize("someone wouldn't have"), - "someone would not have") - self.assertEqual(normalize("someone would've"), "someone would have") - self.assertEqual(normalize("what's the weather like"), - "what is weather like") - self.assertEqual(normalize("that's what I told you"), - "that is what I told you") - - self.assertEqual(normalize("whats 8 + 4"), "what is 8 + 4") - - -if __name__ == "__main__": - unittest.main() diff --git a/test/integrationtests/util/test_platform.py b/test/integrationtests/util/test_platform.py deleted file mode 100644 index 431d14438a93..000000000000 --- a/test/integrationtests/util/test_platform.py +++ /dev/null @@ -1,11 +0,0 @@ -from unittest import TestCase, mock - -from mycroft.util import get_arch - - -class TestPlatform(TestCase): - @mock.patch('os.uname') - def test_get_arch(self, mock_uname): - mock_uname.return_value = ('Linux', 'Woodstock', '4.15.0-39-generic', - 'Awesome test system Mark 7', 'x86_64') - self.assertEqual(get_arch(), 'x86_64') diff --git a/test/integrationtests/util/test_plugins.py b/test/integrationtests/util/test_plugins.py deleted file mode 100644 index de6e8a059634..000000000000 --- a/test/integrationtests/util/test_plugins.py +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2020 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from unittest import TestCase, mock - -import mycroft.util.plugins as mycroft_plugins - - -def get_plug_mock(name): - load_mock = mock.Mock(name=name) - load_mock.name = name - plug_mock = mock.Mock(name=name) - plug_mock.name = name - plug_mock.load.return_value = load_mock - return plug_mock - - -def mock_iter_entry_points(plug_type): - """Function to return mocked plugins.""" - plugs = { - 'mycroft.plugins.tts': [get_plug_mock('dummy'), - get_plug_mock('remote')], - 'mycroft.plugins.stt': [get_plug_mock('dummy'), - get_plug_mock('deepspeech')] - } - return plugs.get(plug_type, []) - - -@mock.patch('mycroft.util.plugins.pkg_resources') -class TestPlugins(TestCase): - def test_load_existing(self, mock_pkg_res): - """Ensure that plugin objects are returned if found.""" - mock_pkg_res.iter_entry_points.side_effect = mock_iter_entry_points - - # Load a couple of existing modules and verify that they're Ok - plug = mycroft_plugins.load_plugin('mycroft.plugins.tts', 'dummy') - self.assertEqual(plug.name, 'dummy') - plug = mycroft_plugins.load_plugin('mycroft.plugins.stt', 'deepspeech') - self.assertEqual(plug.name, 'deepspeech') - - def test_load_nonexisting(self, mock_pkg_res): - """Ensure that the return value is None when no plugin is found.""" - mock_pkg_res.iter_entry_points.side_effect = mock_iter_entry_points - plug = mycroft_plugins.load_plugin('mycroft.plugins.tts', 'blah') - self.assertEqual(plug, None) diff --git a/test/integrationtests/util/test_process_utils.py b/test/integrationtests/util/test_process_utils.py deleted file mode 100644 index d0f329dad173..000000000000 --- a/test/integrationtests/util/test_process_utils.py +++ /dev/null @@ -1,205 +0,0 @@ -from unittest import TestCase, mock - -from mycroft.util.process_utils import (_update_log_level, bus_logging_status, - create_daemon, ProcessStatus, - StatusCallbackMap) - - -class TestCreateDaemon(TestCase): - def test_create(self): - """Make sure deamon thread is created, and runs the expected function. - """ - thread_ran = False - - def thread_func(): - nonlocal thread_ran - thread_ran = True - - thread = create_daemon(thread_func) - self.assertTrue(thread.daemon) - self.assertTrue(thread_ran) - thread.join() - - def test_create_with_args(self): - """Check that the args and kwargs is passed to the thread function.""" - test_args = (1, 2, 3) - test_kwargs = {'meaning': 42, 'borg': '7 of 9'} - passed_args = None - passed_kwargs = None - - def thread_func(*args, **kwargs): - nonlocal passed_args - nonlocal passed_kwargs - passed_args = args - passed_kwargs = kwargs - - thread = create_daemon(thread_func, test_args, test_kwargs) - thread.join() - self.assertEqual(test_args, passed_args) - self.assertEqual(test_kwargs, passed_kwargs) - - -@mock.patch('mycroft.util.process_utils.LOG') -class TestUpdateLogLevel(TestCase): - def test_no_data(self, mock_log): - mock_log.level = 'UNSET' - log_msg = {'msg_type': 'mycroft.debug.log', - 'data': {}} - _update_log_level(log_msg, 'Test') - self.assertEqual(mock_log.level, 'UNSET') - - def test_set_debug(self, mock_log): - mock_log.level = 'UNSET' - log_msg = {'type': 'mycroft.debug.log', - 'data': {'level': 'DEBUG'}} - _update_log_level(log_msg, 'Test') - self.assertEqual(mock_log.level, 'DEBUG') - - def test_set_lowecase_debug(self, mock_log): - mock_log.level = 'UNSET' - log_msg = {'type': 'mycroft.debug.log', - 'data': {'level': 'debug'}} - _update_log_level(log_msg, 'Test') - self.assertEqual(mock_log.level, 'DEBUG') - - def test_set_invalid_level(self, mock_log): - mock_log.level = 'UNSET' - log_msg = {'type': 'mycroft.debug.log', - 'data': {'level': 'snowcrash'}} - _update_log_level(log_msg, 'Test') - self.assertEqual(mock_log.level, 'UNSET') - - def test_set_bus_logging(self, mock_log): - mock_log.level = 'UNSET' - log_msg = {'type': 'mycroft.debug.log', - 'data': {'bus': True}} - self.assertFalse(bus_logging_status()) - _update_log_level(log_msg, 'Test') - self.assertTrue(bus_logging_status()) - - -def create_mock_message(msg_type): - """Creates a mock with members matching a messagebus Message.""" - m = mock.Mock() - m.msg_type = msg_type - m.data = {} - m.context = {} - return m - - -class TestProcessStatus(TestCase): - def test_callbacks(self): - """Assert that callbacks are called as expected.""" - started = False - alive = False - ready = False - stopping = False - error = False - - def started_hook(): - nonlocal started - started = True - - def alive_hook(): - nonlocal alive - alive = True - - def ready_hook(): - nonlocal ready - ready = True - - def stopping_hook(): - nonlocal stopping - stopping = True - - def error_hook(err): - nonlocal error - error = err - - callbacks = StatusCallbackMap(on_started=started_hook, - on_alive=alive_hook, on_ready=ready_hook, - on_stopping=stopping_hook, - on_error=error_hook) - status = ProcessStatus('test', mock.Mock(), callbacks) - - status.set_started() - self.assertTrue(started) - - status.set_alive() - self.assertTrue(alive) - - status.set_ready() - self.assertTrue(ready) - - status.set_stopping() - self.assertTrue(stopping) - - err_msg = 'Test error' - status.set_error(err_msg) - self.assertEqual(err_msg, error) - - def test_init_status(self): - """Check that the status is neither alive nor ready after init.""" - status = ProcessStatus('test', mock.Mock()) - self.assertFalse(status.check_alive()) - self.assertFalse(status.check_ready()) - - def test_alive_status(self): - status = ProcessStatus('test', mock.Mock()) - status.set_alive() - self.assertTrue(status.check_alive()) - self.assertFalse(status.check_ready()) - - def test_ready_status(self): - """Check that alive and ready reports correctly.""" - status = ProcessStatus('test', mock.Mock()) - status.set_alive() - status.set_ready() - self.assertTrue(status.check_alive()) - self.assertTrue(status.check_ready()) - - def test_direct_to_ready_status(self): - """Ensure that process status indicates alive if only ready is set.""" - status = ProcessStatus('test', mock.Mock()) - status.set_ready() - self.assertTrue(status.check_alive()) - self.assertTrue(status.check_ready()) - - def test_error_status(self): - """Ensure that error resets the status and to not alive or ready.""" - status = ProcessStatus('test', mock.Mock()) - status.set_ready() - status.set_error() - self.assertFalse(status.check_alive()) - self.assertFalse(status.check_ready()) - - def test_ready_message(self): - """Assert that ready message contains the correct status.""" - status = ProcessStatus('test', mock.Mock()) - - # Check status when not ready - msg = create_mock_message('mycroft.test.all_loaded') - status.check_ready(msg) - msg.response.assert_called_with(data={'status': False}) - - # Check status when ready - status.set_ready() - msg = create_mock_message('mycroft.test.all_loaded') - status.check_ready(msg) - msg.response.assert_called_with(data={'status': True}) - - def test_is_alive__message(self): - """Assert that is_alive message contains the correct status.""" - status = ProcessStatus('test', mock.Mock()) - status.set_started() - - # Check status when not alive - msg = create_mock_message('mycroft.test.is_alive') - status.check_alive(msg) - msg.response.assert_called_with(data={'status': False}) - - # Check status when ready which should also indicate alive - status.set_ready() - msg = create_mock_message('mycroft.test.is_isalive') - status.check_alive(msg) - msg.response.assert_called_with(data={'status': True}) diff --git a/test/integrationtests/util/test_signal.py b/test/integrationtests/util/test_signal.py deleted file mode 100644 index 93a142ee7dab..000000000000 --- a/test/integrationtests/util/test_signal.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2017 Mycroft AI Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import unittest -from shutil import rmtree - -from os.path import exists, isfile, join -from tempfile import gettempdir - -from mycroft.util import create_signal, check_for_signal - - -class TestSignals(unittest.TestCase): - def setUp(self): - if exists(join(gettempdir(), 'mycroft')): - rmtree(join(gettempdir(), 'mycroft')) - - def test_create_signal(self): - create_signal('test_signal') - self.assertTrue(isfile(join(gettempdir(), - 'mycroft/ipc/signal/test_signal'))) - - def test_check_signal(self): - if exists(join(gettempdir(), 'mycroft')): - rmtree(join(gettempdir(), 'mycroft')) - # check that signal is not found if file does not exist - self.assertFalse(check_for_signal('test_signal')) - - # Check that the signal is found when created - create_signal('test_signal') - self.assertTrue(check_for_signal('test_signal')) - # Check that the signal is removed after use - self.assertFalse(isfile(join(gettempdir(), - 'mycroft/ipc/signal/test_signal'))) - - -if __name__ == "__main__": - unittest.main() diff --git a/test/integrationtests/util/test_string_utils.py b/test/integrationtests/util/test_string_utils.py deleted file mode 100644 index fd65bd16df06..000000000000 --- a/test/integrationtests/util/test_string_utils.py +++ /dev/null @@ -1,9 +0,0 @@ -from unittest import TestCase -from mycroft.util import camel_case_split - - -class TestStringFunctions(TestCase): - def test_camel_case_split(self): - """Check that camel case string is split properly.""" - self.assertEqual(camel_case_split('MyCoolSkill'), 'My Cool Skill') - self.assertEqual(camel_case_split('MyCOOLSkill'), 'My COOL Skill') diff --git a/test/integrationtests/util/test_time.py b/test/integrationtests/util/test_time.py deleted file mode 100644 index 04ad97e86742..000000000000 --- a/test/integrationtests/util/test_time.py +++ /dev/null @@ -1,91 +0,0 @@ -from datetime import datetime -from dateutil.tz import tzfile, tzlocal, gettz -from unittest import TestCase, mock -from mycroft.configuration import setup_locale, set_default_tz -from mycroft.util.time import (default_timezone, now_local, now_utc, to_utc, - to_local, to_system) - -test_config = { - 'location': { - 'timezone': { - 'code': 'America/Chicago', - 'name': 'Central Standard Time', - 'dstOffset': 3600000, # Daylight saving offset in milliseconds - 'offset': -21600000 # Timezone offset in milliseconds - } - } -} - - -@mock.patch('mycroft.configuration.Configuration') -class TestTimeFuncs(TestCase): - def test_default_timezone(self, mock_conf): - # Test missing tz-info - # TODO how to ensure setup_locale() not called by a previous test? - # mock_conf.get.return_value = {} - # self.assertEqual(default_timezone(), tzlocal()) - - # Test tz from config - mock_conf.return_value = test_config - setup_locale() # will load (test) tz from config - self.assertEqual(default_timezone(), - tzfile('/usr/share/zoneinfo/America/Chicago')) - - # Test changing tz - set_default_tz(tzlocal()) - self.assertEqual(default_timezone(), tzlocal()) - - @mock.patch('mycroft.util.time.datetime') - def test_now_local(self, mock_dt, mock_conf): - mock_conf.return_value = test_config - setup_locale() - - dt_test = datetime(year=1985, month=10, day=25, hour=8, minute=18, - tzinfo=default_timezone()) - mock_dt.now.return_value = dt_test - self.assertEqual(now_local(), dt_test) - - expected_timezone = tzfile('/usr/share/zoneinfo/America/Chicago') - mock_dt.now.assert_called_with(expected_timezone) - - now_local(tzfile('/usr/share/zoneinfo/Europe/Stockholm')) - expected_timezone = tzfile('/usr/share/zoneinfo/Europe/Stockholm') - mock_dt.now.assert_called_with(expected_timezone) - - @mock.patch('mycroft.util.time.datetime') - def test_now_utc(self, mock_dt, mock_conf): - mock_conf.return_value = test_config - setup_locale() - - dt_test = datetime(year=1985, month=10, day=25, hour=8, minute=18) - mock_dt.utcnow.return_value = dt_test - - self.assertEqual(now_utc().tzinfo, gettz('UTC')) - - self.assertEqual(now_utc(), dt_test.astimezone(gettz('UTC'))) - mock_dt.utcnow.assert_called_with() - - def test_to_utc(self, mock_conf): - mock_conf.return_value = test_config - dt = datetime(year=2000, month=1, day=1, - hour=0, minute=0, second=0, - tzinfo=gettz('Europe/Stockholm')) - self.assertEqual(to_utc(dt), dt) - self.assertEqual(to_utc(dt).tzinfo, gettz('UTC')) - - def test_to_local(self, mock_conf): - mock_conf.return_value = test_config - dt = datetime(year=2000, month=1, day=1, - hour=0, minute=0, second=0, - tzinfo=gettz('Europe/Stockholm')) - self.assertEqual(to_local(dt), - dt.astimezone(default_timezone())) - self.assertEqual(to_local(dt).tzinfo, default_timezone()) - - def test_to_system(self, mock_conf): - mock_conf.return_value = test_config - dt = datetime(year=2000, month=1, day=1, - hour=0, minute=0, second=0, - tzinfo=gettz('Europe/Stockholm')) - self.assertEqual(to_system(dt), dt) - self.assertEqual(to_system(dt).tzinfo, tzlocal()) diff --git a/test/integrationtests/util/test_xdg.py b/test/integrationtests/util/test_xdg.py deleted file mode 100644 index 56fdd8267682..000000000000 --- a/test/integrationtests/util/test_xdg.py +++ /dev/null @@ -1,27 +0,0 @@ -from unittest import TestCase, mock - -from ovos_config.locations import get_xdg_config_save_path, get_xdg_data_save_path, get_xdg_cache_save_path -from ovos_backend_client.identity import IdentityManager -from mycroft.filesystem import FileSystemAccess -from mycroft.skills.settings import REMOTE_CACHE - - -class TestXdg(TestCase): - - @mock.patch('ovos_config.meta.get_xdg_base') - def test_base_folder(self, mock_folder): - mock_folder.return_value = "testcroft" - self.assertTrue(get_xdg_config_save_path().endswith("/testcroft")) - self.assertTrue(get_xdg_data_save_path().endswith("/testcroft")) - self.assertTrue(get_xdg_cache_save_path().endswith("/testcroft")) - - def test_identity(self): - self.assertTrue(IdentityManager.IDENTITY_FILE.startswith(get_xdg_config_save_path())) - self.assertTrue(IdentityManager.IDENTITY_FILE.endswith("/identity/identity2.json")) - self.assertTrue(IdentityManager.OLD_IDENTITY_FILE not in IdentityManager.IDENTITY_FILE) - - def test_filesystem(self): - self.assertTrue(FileSystemAccess("test").path.startswith(get_xdg_data_save_path())) - - def test_remote_config(self): - self.assertTrue(str(REMOTE_CACHE).startswith(get_xdg_cache_save_path())) diff --git a/test/integrationtests/util/unstripped_lines.txt b/test/integrationtests/util/unstripped_lines.txt deleted file mode 100644 index d8dee8ccdfea..000000000000 --- a/test/integrationtests/util/unstripped_lines.txt +++ /dev/null @@ -1,5 +0,0 @@ - Once upon a time -there was a great Dragon -It was red and cute - - The end diff --git a/test/unittests/test_manager.py b/test/unittests/test_manager.py index ffdd3a8af282..f9f55d43efc4 100644 --- a/test/unittests/test_manager.py +++ b/test/unittests/test_manager.py @@ -24,12 +24,6 @@ def test_handle_settings_file_change(self, mock_log): self.bus.emit.assert_called_once_with(Message("ovos.skills.settings_changed", {"skill_id": "skills"})) mock_log.info.assert_called_once_with(f"skill settings.json change detected for skills") - @patch('ovos_core.skill_manager.is_paired', side_effect=[False, True]) - def test_handle_check_device_readiness(self, mock_is_paired): - self.skill_manager.is_device_ready = MagicMock(return_value=True) - self.skill_manager.handle_check_device_readiness(Message("")) - self.bus.emit.assert_called_once_with(Message('mycroft.ready')) - @patch('ovos_core.skill_manager.find_skill_plugins', return_value={'mock_plugin': 'path/to/mock_plugin'}) def test_load_plugin_skills(self, mock_find_skill_plugins): self.skill_manager._load_plugin_skill = MagicMock(return_value=True) diff --git a/test/unittests/test_skill_manager.py b/test/unittests/test_skill_manager.py index f5cf118d7986..ba9882c9917e 100644 --- a/test/unittests/test_skill_manager.py +++ b/test/unittests/test_skill_manager.py @@ -118,7 +118,7 @@ def test_instantiate(self): 'skillmanager.deactivate', 'skillmanager.keep', 'skillmanager.activate', - 'mycroft.skills.initialized', + #'mycroft.skills.initialized', 'mycroft.network.connected', 'mycroft.internet.connected', 'mycroft.gui.available',