HABApp
HABApp copied to clipboard
Add ability to test rules e.g. with pytest
trafficstars
It would be nice if the rules could be easily tested e.g. with pytest.
Identified things to do:
- [x] Create a way to import rule classes in other files without executing them
- [ ] Mock items
- [ ] Time Travel
- [ ] Bind global states (event bus, item registry) to runtime object
- [ ] Mock runtime object
- [ ] Time travel for item constant watcher
Existing testing implementations DerFetzner nobbi1991
@DerFetzer I've opened this issue so we can track progress here instead of your PR. The rework of the scheduler was lots of work, way more than I anticipated but I have not forgotten about the issue. I'm gradually working on it, but unfortunately time is limited at the moment (as always).
The most difficult thing is that a new rule runner will have to be run asynchronously and that makes things much more difficult ...
Creating rules in an importable way already works:
from HABApp.rule import create_rule,
create_rule(MyRuleClass, arg1)