fix the test

last_state_change isn't updated quick enough.
This commit is contained in:
Benjamin Auquite 2023-04-03 03:29:38 -05:00
commit 96f59f0900

View file

@ -793,8 +793,6 @@ async def test_significant_change(hass):
assert switch._take_over_control
switch._detect_non_ha_changes = True
assert switch._detect_non_ha_changes
switch._alt_detect_method = False
assert not switch._alt_detect_method
# build last service data
await update(force=False)
@ -813,10 +811,8 @@ async def test_significant_change(hass):
assert not switch.turn_on_off_listener.manual_control[ENTITY_LIGHT]
# Assert last_service_data got filled from update()
# Assert last_state_change got filled from update()
await update(force=True)
assert switch.turn_on_off_listener.last_service_data.get(ENTITY_LIGHT) is not None
assert switch.turn_on_off_listener.last_state_change.get(ENTITY_LIGHT) is not None
# Simulate a transition to 255 where the update() is already using brightness 255.
await set_brightness(240)
@ -836,7 +832,7 @@ async def test_significant_change(hass):
switch.hass.helpers.entity_component.async_update_entity = do_nothing
# On next update ENTITY_LIGHT should be marked as manually controlled
await update(force=False)
assert ENTITY_LIGHT in switch.turn_on_off_listener.last_state_change
assert switch.turn_on_off_listener.last_service_data.get(ENTITY_LIGHT) is not None
assert switch.turn_on_off_listener.manual_control[ENTITY_LIGHT]