Write state if schedule update state from async context (#31758)

* Write state if schedule update state from async context

* Fix most tests

* Fix test and PS4 I/O in event loop

* Fix ps4 better
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-02-13 10:22:06 -08:00
1 parent 8d1f8055dd
commit 9e7185c676
8 files changed
+16 -12

No files matched your search

@@ -187,6 +187,7 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person(hass, scanne
# person home switches on
hass.states.async_set(device_1, STATE_HOME)
await hass.async_block_till_done()
await hass.async_block_till_done()
assert all(
light.is_on(hass, ent_id)
@@ -130,6 +130,7 @@ async def test_off_delay(hass, monkeypatch):
async_fire_time_changed(hass, future)
event_callback(on_event)
await hass.async_block_till_done()
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test2")
assert state.state == STATE_ON
assert len(events) == 1
@@ -140,6 +141,7 @@ async def test_off_delay(hass, monkeypatch):
async_fire_time_changed(hass, future)
event_callback(on_event)
await hass.async_block_till_done()
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test2")
assert state.state == STATE_ON
assert len(events) == 2
@@ -149,6 +151,7 @@ async def test_off_delay(hass, monkeypatch):
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test2")
assert state.state == STATE_ON
assert len(events) == 2
@@ -158,6 +161,7 @@ async def test_off_delay(hass, monkeypatch):
with patch(("homeassistant.helpers.event.dt_util.utcnow"), return_value=future):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test2")
assert state.state == STATE_OFF
assert len(events) == 3
+1
View File
@@ -144,6 +144,7 @@ async def test_firing_bus_event(hass, monkeypatch):
# test event for new unconfigured sensor
event_callback({"id": "protocol_0_0", "command": "down"})
await hass.async_block_till_done()
await hass.async_block_till_done()
assert calls[0].data == {"state": "down", "entity_id": DOMAIN + ".test"}
+1
View File
@@ -184,6 +184,7 @@ async def test_firing_bus_event(hass, monkeypatch):
# test event for new unconfigured sensor
event_callback({"id": "protocol_0_0", "command": "off"})
await hass.async_block_till_done()
await hass.async_block_till_done()
assert calls[0].data == {"state": "off", "entity_id": DOMAIN + ".test"}
+1
View File
@@ -214,6 +214,7 @@ async def test_device_defaults(hass, monkeypatch):
# test event for new unconfigured sensor
event_callback({"id": "protocol_0_0", "command": "off"})
await hass.async_block_till_done()
await hass.async_block_till_done()
assert calls[0].data == {"state": "off", "entity_id": DOMAIN + ".test"}