Closed lifeisafractal closed 4 years ago
Rather than try to support that, it's proposed in this PR that we only support appdaemon >=4.x.
As agreed on #32 this is all good, you can break support for <4.x
👍
I pushed 2 commits to resolve the merge conflicts, just FYI :)
I added a small commit -> https://github.com/FlorianKempenich/Appdaemon-Test-Framework/pull/42/commits/31d5a7624c71b0dc1de8c86f04eba421c6a955d0
Let me know what you think. If you think it's overkill we can remove it, no worries 😌
This PR implements a new scheduler simulation for tests. This is in support of the longer term goal of expanded time travel functionality available for tests. This PR aims to not implement any new functionality, but rather setup some underlying architecture to support these goals. This is another smaller step in the direction that the declined #20 was headed.
Overview of longer term design
Hass
class directly in simulations as possible (and by extensions theADAPI
class).Hass
as needed (AppDaemon, Scheduler, etc.)SpyMocks
inHass
to reuse appdeamon functionality along with all the extra functionality of Mocks.ADAPI
async calls, the test framework also needs to support asyncio. In addition to allowing code reuse, this also sets things up to support testing asyncio based automatons in the future.Overview of changes in this PR
AppDaemon
simulation objectsync_wrapper
decorator to synchronize all calls toHass
andADAPI
for use in simulation.SchedulerMocks
implementation intime_travel
and replace with a drop in for appdaeon'sScheduler
for use byADAPI
given_that
andtime_travel
to newScheduler
implementationrun_in
andcancel_timer
fromADAPI
are nowSpyMocks
that reuse the appdeamon implementation leveraging the above simulation work.time_travel
fixture.Follow on work
To get a flavor of where this is going, if this PR gets merged, the next step would be to have the other scheduler functions in
ADAPI
likerun_hourly
also be implemented asSpyMocks
so their behavior is correct and testable. This has some other implications about the simulation (i.e. some operations only allowed before an automation is initialized), which makes new functionality best left for a follow on PR.