Use event loop scheduling for tracking time patterns (#38021)

* Use event loop scheduling for tracking time patterns

* make patching of time targetable

* patch time tests since time can tick to match during the test

* fix more tests

* time can only move forward

* time can only move forward

* back to 100% coverage

* simplify since the event loop time cannot move backwards

* simplify some more

* revert simplify

* Revert "revert simplify"

This reverts commit bd42f232f6.

* Revert "simplify some more"

This reverts commit 2a6c57d514.

* Revert "simplify since the event loop time cannot move backwards"

This reverts commit 3b13714ef4.

* Attempt another simplify

* time does not move backwards in the last two

* remove next_time <= now check

* fix previous merge error
This commit is contained in:
J. Nick Koston 2020-07-20 20:18:31 -10:00 committed by GitHub
parent 7bc8caca96
commit 60009ec2f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 404 additions and 199 deletions

View file

@ -46,7 +46,11 @@ async def test_if_fires_using_at(hass, calls):
},
)
async_fire_time_changed(hass, dt_util.utcnow().replace(hour=5, minute=0, second=0))
now = dt_util.utcnow()
async_fire_time_changed(
hass, now.replace(year=now.year + 1, hour=5, minute=0, second=0)
)
await hass.async_block_till_done()
assert len(calls) == 1