Commit Graph

174 Commits (mark-ii/gui-replace-page)

Author SHA1 Message Date
Åke Forslund 46c8a6b51f Add Voight Kampff support setting configurations
Adds the "Given the user's {config} is {value}" step implementation

This will patch the configuration with a section from a dictionary that
can either be a global (shipped in
mycroft/res/{lang}/configurations.json) or shipped with the test
definition. The file should be named the same as the feature file but
instead of ".feature" the extension should be ".config.json".

mycroft/res/text/en-us/configurations.json contains a couple of
pre-defined configurations that can be applied
- units (metric/imperial)
- location (Stockholm)

After each scenario any applied patch will be cleared
2020-05-18 14:48:14 +02:00
Bart Ribbers 4d01269f35
Explicitely run the messagebus test with Python3
/usr/bin/python might not always point to Python 3, and it might not
even exist, depending on the distribution. To make sure we always run
with Python 3, explicitely call /usr/bin/python3

Also update the service start command and remove the outdated message
method tests
2020-05-06 14:28:27 +02:00
Kris Gesling 1a96f04020 Add single Voight Kampff module interface
Takes in arguments for both test_setup.py and behave test runner. Parses
any args for test_setup and passes any remaining arguments to behave.

This moves argparsing out of the test_setup main() allowing the helper commands
to pass in pre-parsed arguments rather than adding logic inside main to
differentiate between a list and a preparsed arument object
2020-03-25 07:40:01 +01:00
Åke Forslund 9fe158d841 Prepare for multi-lang support 2020-03-24 10:42:07 +01:00
Åke Forslund 00c83c5139 Add repo and branch selection for test_setup.py
--url can be added to specify the repo url
--branch can be added to specify a specific branch
2020-03-24 10:42:07 +01:00
Åke Forslund c33f9ee875 Restructure test_setup.py according to review 2020-03-24 10:42:07 +01:00
Åke Forslund f8c6107ea5 Update readme with some new steps 2020-03-24 10:42:07 +01:00
Åke Forslund 8e7e19ecc2 Add help text to test_setup.py parameters 2020-03-24 10:42:07 +01:00
Åke Forslund daeac964e0 Rename tested-skills argument to test-skills 2020-03-24 10:42:07 +01:00
Åke Forslund 5d6cb83899 Make all fields in config optional 2020-03-24 10:42:07 +01:00
Åke Forslund e0dec90d17 Allow test_setup to update skills 2020-03-24 10:42:07 +01:00
Åke Forslund 2a7b0ccef9 Update voight kampff Readme with some extra info 2020-03-24 10:42:07 +01:00
Åke Forslund a6d1e91942 Add auto-retry
This switches behave to the current dev release including the autoretry
system.
2020-03-24 10:42:07 +01:00
Åke Forslund 0ad91ce321 Add an event that can be waited on instead of sleep 2020-03-24 10:42:07 +01:00
Åke Forslund 0f860162e3 Update run_test_suite.sh
- Pulseaudio is launched if on CI
- remove hard-coding of start-mycroft.sh
2020-03-24 10:42:02 +01:00
Åke Forslund 353239cbc2 Move more common functions to voight kampff tools 2020-03-23 11:41:13 +01:00
Åke Forslund 0d5520be4a Reduce sleep time while waiting for response 2020-03-23 11:41:13 +01:00
Åke Forslund 2055b50238 Add before_feature logging current test 2020-03-23 11:41:13 +01:00
Åke Forslund fa88562a8c Fix timeout of wait for message
The counter didn't increment as intended
2020-03-23 11:41:13 +01:00
Åke Forslund 9a5f1f6f7e Add shared tools 2020-03-23 11:41:13 +01:00
Åke Forslund 0ea1af126d Reduce safety timeouts 2020-03-23 11:41:13 +01:00
Åke Forslund d451e1c1e0 Add more info on captured response (skill and dialog) 2020-03-23 11:41:13 +01:00
Åke Forslund b79fe04eb8 Extend timeout after scenario 2020-03-23 11:41:13 +01:00
Åke Forslund 51f07a5d96 Add assert message if no dialog is recorded 2020-03-23 11:41:13 +01:00
Åke Forslund c159377acb Consume matched messages. 2020-03-23 11:41:13 +01:00
Åke Forslund b43785a403 Recreate messed up assert messages 2020-03-23 11:41:13 +01:00
Åke Forslund 1470151c2b Add alternatives for user replies 2020-03-23 11:41:13 +01:00
Åke Forslund 0c873b5065 Update skill list for default skills test 2020-03-23 11:41:13 +01:00
Åke Forslund 75f92a66dd Add handler to capture messages of specific type 2020-03-23 11:41:13 +01:00
Åke Forslund 12f2e63cc3 Share only identity and allure in separate volume
- Sharing only the identity file removes the need for clearing the skill
sandbox dir and padatious cache
- Make things a bit cleaner with separate Allure volume
2020-03-23 11:41:13 +01:00
Åke Forslund 2592c9b1c2 Add clearer feedback on failures
Will now print all responses received from Mycroft
2020-03-23 11:41:13 +01:00
Åke Forslund 15148fadf5 Rework bus hooks
Override the bus clients on_message method and collect all messages in a
list. This will make it harder to miss a message during a test
2020-03-23 11:41:13 +01:00
Åke Forslund 38d43f2bb7 Move Jenkins specific commands into Jenkinsfile
Allure commandline and chown command are now run through the Jenkinsfile
instead of through the run_test_suite.sh
2020-03-23 11:41:13 +01:00
Chris Veilleux b436e5575a Add allure test reports
Behave will generate test results in the allure format, this will be
picked up by Jenkins and sent of to a standalone webserver.
2020-03-23 11:41:13 +01:00
Åke Forslund fc9c462a37 Add possibility to send a user response as Then step 2020-03-23 11:41:13 +01:00
Åke Forslund 4a1dbd7e04 Add dockerfile for running voight_kampff test 2020-03-23 11:41:13 +01:00
Åke Forslund b4507b7866 Add Voight Kampff test
The Voight kampff test is an integration test collecting and running
behave test of skills.
2020-03-23 11:41:09 +01:00
Åke Forslund 8e12aee1dc Remove refs to Settings class from skill tester
Skill tester used a "mocked" skill test class overriding some methods.
This is no longer necessary since a normal dict will work just as well.
2020-02-27 08:07:12 +01:00
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
Å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
Matthew D. Scholefield 154ccd59d7 Expose single threaded training option from Padatious Service
This is necessary to prevent a deadlock when training during intent tests using pytest
2018-05-14 14:27:37 -05:00
Åke Forslund 921bc5f23d Add support for "expected dialog"
Loads dialogs and checks if any skills responds with one of the possible
dialogs.
2018-05-14 14:27:37 -05:00