Fix sun test to patch time since it is now refetched (#39372)

This accounts for the fix in #39335
This commit is contained in:
J. Nick Koston 2020-08-28 22:06:06 -05:00 committed by GitHub
parent 4682de5ac1
commit 67de1d3466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,11 +120,12 @@ async def test_state_change(hass, legacy_patchable_time):
assert sun.STATE_BELOW_HORIZON == hass.states.get(sun.ENTITY_ID).state
hass.bus.async_fire(
ha.EVENT_TIME_CHANGED, {ha.ATTR_NOW: test_time + timedelta(seconds=5)}
)
await hass.async_block_till_done()
patched_time = test_time + timedelta(seconds=5)
with patch(
"homeassistant.helpers.condition.dt_util.utcnow", return_value=patched_time
):
hass.bus.async_fire(ha.EVENT_TIME_CHANGED, {ha.ATTR_NOW: patched_time})
await hass.async_block_till_done()
assert sun.STATE_ABOVE_HORIZON == hass.states.get(sun.ENTITY_ID).state