Commit Graph

76 Commits (3efce9639e6764041d3bc6866d8402f00a11cf2f)

Author SHA1 Message Date
Å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
Åke Forslund c8b58f3f37 Inject message type as __type__ in the test data 2018-05-14 14:27:37 -05:00
Åke Forslund dc58402f39 Fix message_tester.py
Make skill optional and disable expected_dialog if missing.
2018-05-14 14:27:37 -05:00
Åke Forslund e6017ec496 Fix issues detected by codacy 2018-05-14 14:27:37 -05:00
Åke Forslund 4a7cf45ada Add possibility to add a custom test runner
The custom test runner can be used for mocking third-party applications
or services.

To use create a __init__.py in the SKILL_DIR/test

The base of the file should look something like:

```python
from test.integrationtests.skills.skill_tester import SkillTest

def skill_runner(skill, example, emitter, loader, m1, m2):
    return SkillTest(skill, example, emitter).run(loader)
```

Then the skill_runner can be decorated by `mock.patch` to mock out resources.
2018-05-14 14:27:37 -05:00
Åke Forslund cab556450e Add expected_data option
Allows the intent test to check expected data content.

Example:

{
  "utterance": "set a weekend alarm at  9 am",
  "expected_data": {
      "ampm": "am",
      "time": "9",
      "daytype": "weekend"
  },
  "expected_response": "Okay. Setting a .* alarm"
}
2018-05-14 14:27:37 -05:00
Åke Forslund 9c4ac178b9 Give better feedback when skill isn't loaded
If a skill required for a test case isn't loaded an exception will be
raised.
2018-05-14 14:27:37 -05:00
Åke Forslund 3917726bb5 Use queue to get skill completion
This allows the skill test to exit directly after skill handler
completes.
2018-05-14 14:27:37 -05:00
Åke Forslund e7ead7ca6e Reduce timeout when skill has been handled 2018-05-14 14:27:37 -05:00
Matthew D. Scholefield 79bf94e48e Speed up intent tests by responding to converse requests 2018-05-14 14:27:37 -05:00
Åke Forslund 02565efd59 Use pytest to discover test cases 2018-05-14 14:27:37 -05:00