Closed ProjectMoon closed 7 months ago
1.
The __init__.py
in the test folder is intended for setting the test environment for the intent test so I suggest a separate file.
I prefer the python builtin unittest framework for simplicity.
2.
Indeed it's not fool proof, as you suggest indexing the last with [-1]
would probably be an easy improvement. We should definitely look if that information can be fetched more reliably at a later time.
Thanks for fixing this I'll do a quick test run of it tomorrow and then merge it if nothing terrible (ominous thunder) happens during the test run.
I want to add unit tests first. Also I need to double check something with the -1 index.
Yes, need to add an if check. Splitting on a non existent token and grabbing the -1 index will give you the original string.
So, the code relies on the mycroft
module, which does not seem to be available to import from the Mycroft Skills Kit. Am I doing something wrong? The documentation says it should be in mycroft.skills
. But adding the msk package doesn't have a mycroft
module.
This is blocking me from creating the tests.
mycroft-core sets up and runs in it's own virtualenv. to access the mycroft package you need to activate that venv. in the mycroft-core folder there is a venv-activate.sh file. Running source venv-activate.sh
from the mycroft-core folder should be enough to make it available when running the unittest.
Let me know if something's unclear or if this doesn't work.
Is there a better way to get the unit test working in isolation, without requiring a full installation of Mycroft locally?
If you want to test the mopidypost file alone, this is what I could get going:
python3 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt
pip install requests
pip install pytest
__init__.py
file in the foldertest_mopidypost.py
file in the new folder, the file imports mopidypost
and defines
the test casesthen you should be able to run pytest test_mopidypost.py
to test the mopidypost module.
Edit: Needed to do some submodule rejiggering to get pytest to leave mycroft entirely out of things.
This fixes the skill crashing when encountering weird album names in GMusic responses from Mopidy.
Open items:
test/__init__.py
or should I make a separate test file? Also, what unit test framework?-
in their name? That will produce weird results. I imagine it would be very uncommon, but still possible. A suggestion would be to probably take the last entry in the split array, rather than always the second (included in this PR).