Developing service plugins: Software tests and interactive invocation
See original GitHub issueHi again,
@psyciknz mentioned at https://github.com/jpmens/mqttwarn/issues/516#issuecomment-863526629:
But what I might look at, and is probable a better direction for the project, is to create, in this case, a
test_pushover.py
test class for testing/debugging.
This can go into two directions. I hope that both variants will be helpful to you.
Software tests
8596c14a (from the “amo/service-tests” branch) adds some software tests for the pushover service plugin, with every real network interaction completely mocked. The corresponding tests can be invoked using
# Populate sandbox.
git clone https://github.com/jpmens/mqttwarn
git checkout amo/service-tests
python3 -m venv .venv
source .venv/bin/activate
# Install package for development and testing.
pip install --editable=.[test]
# Run all software tests for "pushover" service plugin.
pytest -vvv -k test_pushover
Interactive use
Since mqttwarn 0.10.0, it is possible to directly invoke notification plugins from the command line, as implemented by af3288bc. For the pushover notification plugin, that might look like
mqttwarn \
--plugin=pushover \
--data='{"title": "About", "message": "Hello world", "addrs": ["userkey", "token"], "priority": 6}'
For this to work, you will currently still have to configure a [config:pushover]
section within your mqttwarn.ini
. However, you can leave it completely empty, as the relevant parameters will be given on the command line. #527 will improve this situation once more - with that patch, service plugins can be invoked without needing any mqttwarn.ini
configuration file at all.
With kind regards, Andreas.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
I think all is fine. It was a while ago all this was discussed. I’ve certainly not run up against any problems recently
Dear @psyciknz,
a074a49af315 was needed to make the example outlined above actually work. Do you think this satisfies your needs?
With kind regards, Andreas.