Commit Graph

86 Commits (a508464b01f0063c94271149d2db60fbb68e5f2c)

Author SHA1 Message Date
maxbachmann 7a48297132 cleanup python2 unicode 2019-11-26 23:09:32 +01:00
Åke Forslund af79c7c2d2 Make skill's logging visible
The skill logger was still set to the temporary logger, this resets it
to the intended logger name and handler
2019-10-10 09:19:59 +02:00
Åke Forslund 48e93f3504 Fix TestSettings
Updates the settings to work with the new ones
2019-09-25 13:01:45 +02:00
Åke Forslund 3b2c7267e7 Rename Message type arg to msg_type
Name change to remove collision with the builin type.
2019-09-02 13:30:55 +02:00
Åke Forslund edc6192124 Reduce complexity of EvaluationRule
Creates rules.py containing logic for the small rule snippets for each
entry in the json
2019-09-02 10:03:45 +02:00
Åke Forslund f35ccae83b Fix broken startup log capture 2019-09-02 10:03:45 +02:00
Åke Forslund 69231c5ed1 Make execute_test less complex
Split the long function into several smaller ones just retaining the
main logic.
2019-09-02 10:03:45 +02:00
Åke Forslund 98c1a74ce8 Add dummy wait_for_response() method to test emitter 2019-09-02 10:03:45 +02:00
Chris Veilleux 3bd3dd1bed Refactor skill manager (#2237)
Split skill_manager into three separate classes, SkillManager, SkillUpdater and SkillLoader splitting the responsibility into logical units

* Split the SkillManager.__init__ code to determine the download times into a new method
* Make docstrings consistent and PEP257 compliant.  Also fixed a couple of spelling errors
* fixed two issues introduced in the previous refactoring
* removed unnecessary assignment of an instance attribute to a local variable
* updated the unit test to mock out code that reaches outside of core, like MSM and the configuration manager.
* add several unittests and refactored load_priority method.
* add a test for the _get_last_modified_date function.
* add "quick" argument to docstring
* removed unused import
* new class containing the logic to periodically update/install skills and send skill manifests to the backend.
* import MsmException from where it is defined, not from the skill manager.
* add some logging to the skill updater
* remove code now in SkillUpdater from SkillManager
* added imports to __init__.py to define the API into the message bus package
* new base class for unit tests and module for reusable mocks
* new skill loader class that will replace the _load_or_reload_skill() method in the SkillManager class.
* moved skill loading logic from core.py into skill_loader.py, resulting in some refactoring of skill loader and skill manager.  change unit tests to match.
* added back some spacing that was inadvertently removed.
* change skill tester to use new SkillLoader class.
* Separate reload required check from performing reload to make logic easier
to follow
* Track skills that failed to load to handle infinite loop at first load
if skill fails to load
* Allow reloading skills that has failed to load
* Simplify first load of skills
- create activate, deactivate and unload methods for skill_loader
objects
- add sanity checks before activating and deactivating skills
- Update activation/deactivation test cases
2019-08-20 12:02:39 +02:00
Chris Veilleux d8f3095d40 Rename the message bus client and abstract config loading
Message bus config loading is now shared by service and client.

messagebus.client.ws file is still available in case skills are using it. It is a backport that inherits from the new MessageBusClient class. Adds depreciation warning.
2019-07-19 08:16:54 +02:00
Åke d1ac0ca85d Add gui related messages to list of hidden messages (#2170)
These currently mainly clutter up the logs
2019-06-20 17:01:20 -05:00
Åke 1b69c5ab4a Feature/common qa skill test (#2097)
* Refactor skill test input utterances

Slight cleanup to make adding more different cases easier.

* Add test for common QA

"question" can now be used instead of "utterance" to test a common qa skill
2019-05-13 10:16:04 -07:00
Åke 2b8bf1d94c Restore get_response method after skill test is done (#2100)
Slight refactoring to allow simple save and restore for skill members.
2019-04-17 11:39:08 -05:00
Matthew D. Scholefield 21c2849106
Merge pull request #2046 from forslund/bugfix/skill-tester-dialogs
Fix dialog check in skill tester
2019-03-13 09:58:52 -05:00
Åke Forslund a7a4853e58 Fix dialog check in skill tester
Merge consecutive .*'s into a single .*

The process for "{{modifier}} {{precip}} is expected on {{day}}" will first
replace the {{}} by .* as previously:

".* .* is expected on .*"

then a second pass is made replacing any consecutive .* resulting in

".* is expected on .*"
2019-03-09 09:25:29 +01:00
Åke Forslund 1602e74a3a Fix context handling 2019-03-06 14:28:12 +01:00
Åke 4bacdeaee6 Let skill tester expand dialogs (#2007)
* Let skill tester expand dialogs

The skill tester need to expand the dialogs in the same way as the dialog renderer to be able to correctly assert the expected_dialog criteria.

* Minor docstring changes
2019-02-28 00:55:08 -06:00
Kris Gesling 6bfe8e26b0
Fix typo: "excepected" > "expected" 2019-02-24 17:04:14 +09:30
Åke Forslund 7dcffab3f9 include skill_id in response
The intent_service now require the skill_id field to exist in the response, the converse request response now respons with the requested skill_id
2018-11-21 10:56:13 +01:00
Åke 3fc39e8ed2 Skilltester extension for Common Playback Skill functions (#1864)
* Add lt and gt to skill tester evaluation vocabulary

lt returns True if message item is LESS THAN the value in the config
gt returns True if message item is GREATER THAN the value in the config

* Add separate Exception for Skilltest errors

* Add support for common playback skill messages

CPS_query:

new test json possibilities
play_query: Emits a message that can be catched by CPS_match_query_phrase()
play_query_match: Structure with info of the expected match
  "phrase": matched phrase
  "confidence_threshold": The minimum confidence the phrase should result in

Example:
{
  "play_query": "the news",
  "play_query_match": {
    "phrase": "the news",
    "confidence_threshold":  0.8
  }
}

"play_start": Emits message that can be catched by CPS_start using sub-fields.
  "phrase": matched phrase
  "callback_data": dict with info for the function

Example:
{
  "play_start": {
    "phrase": "the news",
    "callback_data": {
    }
  },
  "expected_data": {"__type__": "mycroft.audio.service.play"}
}
2018-11-16 17:58:17 -06:00
Matthew D. Scholefield 6f0489423c
Merge pull request #1618 from forslund/feature/test-report-loading-issues
Add info when skill fails to load during tests
2018-10-15 11:21:49 -05:00
Åke Forslund 8a77892821 Fix test_setup issue in discover_test.py 2018-09-26 09:58:52 +02:00
Michael Nguyen 881de18db4
Merge pull request #1786 from forslund/test/test-setup
Test/test setup
2018-09-25 11:40:56 -05:00
Åke 92b04b36b1 Fix incorrect escape sequences found by skill test (#1797)
One occurence in dialog/__init__.py and one in skill_tester.py
2018-09-24 03:09:44 -05:00
Åke Forslund 7cfd7ea019 Add info when skill fails to load during test
The skill log is redirected to a string during loading and if the skill
fails to load the loading logs are outputed when the first test for the
skill is executed.
2018-09-14 14:01:46 +02:00
Åke 530701cb9a Allow multiple dialogs and responses (#1791)
Allowing multiple dialog choices can help in cases where a skill has a number of dialog files that each can be triggered independently by the same intent.  For example, the weather skill inquiry "will it rain" can trigger either a response when there is an upcoming rain and another if there's no rain in the near future.
```
"expected_dialog": ["dialog1", "dialog2"]
```
and
```
"expected_response": ["text 1", "text 2"]
```
is now possible. This will pass the test if a line from either dialog1 or dialog2 is matched. (or "text 1" or "text 2" is matched for "expected_response")
2018-09-12 18:16:27 -05:00
Åke Forslund 542dbbe863 Add a "test_env" config value when running tests
The skill can check for this in their code

if 'test_env' in self.config_core:
    test_this()

allowing some basic workarounds in the skill init stage.
2018-09-07 18:53:40 +02:00
Åke Forslund 788090ad6a Add support for a test_setup() function
The test setup function will be run after the skill is loaded but before the testing starts.

This provides a place to setup things that is standard for all test cases.
2018-09-07 18:51:30 +02:00
Åke 787ff63d2b Remove trailing references to MycroftSkill.emitter (#1768)
- references in skill_tester.py
- when going through the methods to check for decorations the emitter
was triggered and generated a Warning
2018-08-28 12:26:46 -05:00
Åke 3d18df3d6d Add support for separate settings for test (#1753)
The json can now include a "settings" entry which will replace the skill's self.settings for that particular test.
2018-08-21 20:50:06 -05:00
Steve Penrod 6dc46e8c0c Enhance tester output
Several visual changes to the logs (no functional difference)
* Added 'with' to close test_case_file, quieting warning
* Highlight Mycroft's utterannces in output and moved print to fix order of printing
* Better highlight sending a response
* Highlight the test utterance
2018-08-21 04:03:03 -05:00
Åke 3986d1fbb0 Handle remove_all_listeners (#1742)
Allow the test mocked emitter to handle emitter.remove_all_listeners
2018-08-15 03:32:12 -05:00
Steve Penrod dd807b2b2e
Improve the standalone skill tester (#1683)
* Improve the standalone skill tester

Using the skill tester was difficult -- the skill author had to copy a file
locally, and figuring out what was wrong with a test wasn't obvious.  This
change improves it in several ways:
* The tester can now be run as a module, allowing any skill to be tested
  by entering the skill folder and running:
  ```
  python -m test.integrationtests.skills.runner
  ```
  Optionally you can pass along a path to the skill.
* The runner will display help with a '--help' parameter, pointing to
  documentation on creating the tests.
* Information on where the tests are expected is printed during execution
* The *.intent.json was reduced to simply *.json since this is under an
  ```test/intent/``` folder already.  (This is backwards compatible for
  existing intent tests.)
* The failing rule is now displayed at the bottom of the run report, making
  it easier to figure out where issues exist during test creation
* Headers and terminal colors are used in the output, making it easier to
  visually parse the output from the execution of tests.

====  Documentation Notes ====
Update the skill documentation to reflect using
  python -m test.integrationtests.skills.runner
instead of copying the skill_developers_testrunner.py.

NOTE: This does have to be performed within a developer venv in order to
access the test suite.  Consider moving this into a mycroft-core-dev package
in the future for Mark 1 / Picroft users.

* Quieting warning from Codacy

* Replace single_test with runner

Adds support for "test_env" to the runner script

* Update the discover_test to match the runner

- catch intent tests from *.json files
- add failure msg to assert

* Turn off color using MST_NO_COLOR env variable
2018-07-19 02:23:22 -05:00
Åke b1408617bc CLI Feature: skill commands (#1612)
* Update format for skill listing

Now send the skills with id and active status

* Add commands to activate/deactivate skills

* Add "unload all except one" functionallity

* Update after rebasing

- fix identifying skills

* Unload skills if they're removed from disk

* Rename _shutdown to default_shutdown

The method is not intended to be non-public, and this should shut up
codacy bot.

* Handle keep command without argument

* Add new commands to help

- Split help into multiple pages as needed

* Support :activate all
2018-06-22 00:59:51 -05:00
Åke Forslund 4ec255493b Add intent_type checks for padatious 2018-06-01 15:05:10 +02:00
Åke Forslund b8b60abff0 Improve 'or' logic
'or' would fail trying to parse 'succeeded'
2018-06-01 15:04:49 +02:00
Matthew D. Scholefield a5b3b6f9e4 Add support for SKILL_DIR variable to execute just one skill test 2018-05-31 19:18:15 -05:00
Matthew D. Scholefield cc582ce38c Fix starting skillstest via start-mycroft.sh
This also removes the ability to pass the skills dir as the first argument. Instead this was moved to an environment variable called SKILLS_DIR to prevent conflict with pytest arguments
2018-05-31 19:17:26 -05:00
Åke Forslund d25b679bd9 Don't force types for expected_data
Forcing all content to string limits the amount of tests that can be run with this. For example a list of strings will fail. This keeps the original type from the json
2018-05-29 16:54:04 +02:00
Åke Forslund e7a6a20967 Sort test cases so order is enforced 2018-05-28 15:32:56 +02:00
Åke Forslund d99377dc78 Fix discover_test get_skills_dir()
The discover_test didn't handle configurable data path correctly.
2018-05-28 09:10:35 +02:00
Matthew D. Scholefield 14ceb1f1dd Remove all references to /opt/mycroft/skills
The only thing that should reference it is the config
2018-05-23 08:22:14 +02:00
CarstenAgerskov a353c43748 Fixes for Python3 migration 2018-05-21 18:45:47 -05:00
Åke Forslund b9cb58be79 Fix single_test.py
Update metaclass declaration to python3 syntax
2018-05-21 15:42:16 +02:00
Åke Forslund 580c053e22 Use skill id similar to the normal loading
Fixes issues with skills using regexes.
2018-05-21 15:21:38 +02:00
Matthew D. Scholefield 7ef551ddc6 Fix error with skills test descriptor 2018-05-14 14:27:37 -05:00
Matthew D. Scholefield 0850f5073a Fix tests for Python 3
- Change print statements
 - Change queue import
2018-05-14 14:27:37 -05:00
Åke Forslund 40fd0487d0 Clean up output slightly
The converse request / response messages are now hidden.
2018-05-14 14:27:37 -05:00
Åke Forslund 83a6be7fcb Override get_response to handle conversations
Adds the possibility to add a responses list in the test case. The test
will respond with each of the entries in the list to get_response
requests.

Ex:
{
  [...]
  "responses": ["yes", "Miami"]
}
2018-05-14 14:27:37 -05:00
Åke Forslund ce410c2f0c Fix expected_data
expected_data would fail in combination with Intent tests, this
differentiates it from the other rules
Add message type as "__type__" in the data for processing using
expected_data.
2018-05-14 14:27:37 -05:00