Use async_write_ha_state in tests (#91333)
This commit is contained in:
parent
208a44e437
commit
d320c73fb7
2 changed files with 14 additions and 14 deletions
|
@ -128,7 +128,7 @@ async def test_sync_message(hass: HomeAssistant, registries) -> None:
|
|||
)
|
||||
light.hass = hass
|
||||
light.entity_id = "light.demo_light"
|
||||
await light.async_update_ha_state()
|
||||
light.async_write_ha_state()
|
||||
|
||||
# This should not show up in the sync request
|
||||
hass.states.async_set("sensor.no_match", "something")
|
||||
|
@ -268,7 +268,7 @@ async def test_sync_in_area(area_on_device, hass: HomeAssistant, registries) ->
|
|||
)
|
||||
light.hass = hass
|
||||
light.entity_id = entity.entity_id
|
||||
await light.async_update_ha_state()
|
||||
light.async_write_ha_state()
|
||||
|
||||
config = MockConfig(should_expose=lambda _: True, entity_config={})
|
||||
|
||||
|
@ -360,19 +360,19 @@ async def test_query_message(hass: HomeAssistant) -> None:
|
|||
)
|
||||
light.hass = hass
|
||||
light.entity_id = "light.demo_light"
|
||||
await light.async_update_ha_state()
|
||||
light.async_write_ha_state()
|
||||
|
||||
light2 = DemoLight(
|
||||
None, "Another Light", state=True, hs_color=(180, 75), ct=400, brightness=78
|
||||
)
|
||||
light2.hass = hass
|
||||
light2.entity_id = "light.another_light"
|
||||
await light2.async_update_ha_state()
|
||||
light2.async_write_ha_state()
|
||||
|
||||
light3 = DemoLight(None, "Color temp Light", state=True, ct=400, brightness=200)
|
||||
light3.hass = hass
|
||||
light3.entity_id = "light.color_temp_light"
|
||||
await light3.async_update_ha_state()
|
||||
light3.async_write_ha_state()
|
||||
|
||||
events = async_capture_events(hass, EVENT_QUERY_RECEIVED)
|
||||
|
||||
|
@ -931,7 +931,7 @@ async def test_unavailable_state_does_sync(hass: HomeAssistant) -> None:
|
|||
light.hass = hass
|
||||
light.entity_id = "light.demo_light"
|
||||
light._available = False
|
||||
await light.async_update_ha_state()
|
||||
light.async_write_ha_state()
|
||||
|
||||
events = async_capture_events(hass, EVENT_SYNC_RECEIVED)
|
||||
|
||||
|
@ -1025,7 +1025,7 @@ async def test_device_class_switch(
|
|||
)
|
||||
sensor.hass = hass
|
||||
sensor.entity_id = "switch.demo_sensor"
|
||||
await sensor.async_update_ha_state()
|
||||
sensor.async_write_ha_state()
|
||||
|
||||
result = await sh.async_handle_message(
|
||||
hass,
|
||||
|
@ -1072,7 +1072,7 @@ async def test_device_class_binary_sensor(
|
|||
)
|
||||
sensor.hass = hass
|
||||
sensor.entity_id = "binary_sensor.demo_sensor"
|
||||
await sensor.async_update_ha_state()
|
||||
sensor.async_write_ha_state()
|
||||
|
||||
result = await sh.async_handle_message(
|
||||
hass,
|
||||
|
@ -1123,7 +1123,7 @@ async def test_device_class_cover(
|
|||
sensor = DemoCover(None, hass, "Demo Sensor", device_class=device_class)
|
||||
sensor.hass = hass
|
||||
sensor.entity_id = "cover.demo_sensor"
|
||||
await sensor.async_update_ha_state()
|
||||
sensor.async_write_ha_state()
|
||||
|
||||
result = await sh.async_handle_message(
|
||||
hass,
|
||||
|
@ -1170,7 +1170,7 @@ async def test_device_media_player(
|
|||
sensor = AbstractDemoPlayer("Demo", device_class=device_class)
|
||||
sensor.hass = hass
|
||||
sensor.entity_id = "media_player.demo"
|
||||
await sensor.async_update_ha_state()
|
||||
sensor.async_write_ha_state()
|
||||
|
||||
result = await sh.async_handle_message(
|
||||
hass,
|
||||
|
@ -1454,7 +1454,7 @@ async def test_sync_message_recovery(
|
|||
)
|
||||
light.hass = hass
|
||||
light.entity_id = "light.demo_light"
|
||||
await light.async_update_ha_state()
|
||||
light.async_write_ha_state()
|
||||
|
||||
hass.states.async_set(
|
||||
"light.bad_light",
|
||||
|
|
|
@ -536,7 +536,7 @@ async def test_async_remove_no_platform(hass: HomeAssistant) -> None:
|
|||
ent = entity.Entity()
|
||||
ent.hass = hass
|
||||
ent.entity_id = "test.test"
|
||||
await ent.async_update_ha_state()
|
||||
ent.async_write_ha_state()
|
||||
assert len(hass.states.async_entity_ids()) == 1
|
||||
await ent.async_remove()
|
||||
assert len(hass.states.async_entity_ids()) == 0
|
||||
|
@ -577,7 +577,7 @@ async def test_set_context(hass: HomeAssistant) -> None:
|
|||
ent.hass = hass
|
||||
ent.entity_id = "hello.world"
|
||||
ent.async_set_context(context)
|
||||
await ent.async_update_ha_state()
|
||||
ent.async_write_ha_state()
|
||||
assert hass.states.get("hello.world").context == context
|
||||
|
||||
|
||||
|
@ -593,7 +593,7 @@ async def test_set_context_expired(hass: HomeAssistant) -> None:
|
|||
ent.hass = hass
|
||||
ent.entity_id = "hello.world"
|
||||
ent.async_set_context(context)
|
||||
await ent.async_update_ha_state()
|
||||
ent.async_write_ha_state()
|
||||
|
||||
assert hass.states.get("hello.world").context != context
|
||||
assert ent._context is None
|
||||
|
|
Loading…
Add table
Reference in a new issue