mirror of
https://github.com/home-assistant/core.git
synced 2025-11-10 03:19:34 +00:00
Entity to handle updates via events (#24733)
* Entity to handle updates via events * Fix a bug * Update entity.py
This commit is contained in:
@@ -104,12 +104,12 @@ async def test_dump_data(hass):
|
||||
entity = Entity()
|
||||
entity.hass = hass
|
||||
entity.entity_id = 'input_boolean.b0'
|
||||
await entity.async_added_to_hass()
|
||||
await entity.async_internal_added_to_hass()
|
||||
|
||||
entity = RestoreEntity()
|
||||
entity.hass = hass
|
||||
entity.entity_id = 'input_boolean.b1'
|
||||
await entity.async_added_to_hass()
|
||||
await entity.async_internal_added_to_hass()
|
||||
|
||||
data = await RestoreStateData.async_get_instance(hass)
|
||||
now = dt_util.utcnow()
|
||||
@@ -144,7 +144,7 @@ async def test_dump_data(hass):
|
||||
assert written_states[1]['state']['state'] == 'off'
|
||||
|
||||
# Test that removed entities are not persisted
|
||||
await entity.async_will_remove_from_hass()
|
||||
await entity.async_remove()
|
||||
|
||||
with patch('homeassistant.helpers.restore_state.Store.async_save'
|
||||
) as mock_write_data, patch.object(
|
||||
@@ -170,12 +170,12 @@ async def test_dump_error(hass):
|
||||
entity = Entity()
|
||||
entity.hass = hass
|
||||
entity.entity_id = 'input_boolean.b0'
|
||||
await entity.async_added_to_hass()
|
||||
await entity.async_internal_added_to_hass()
|
||||
|
||||
entity = RestoreEntity()
|
||||
entity.hass = hass
|
||||
entity.entity_id = 'input_boolean.b1'
|
||||
await entity.async_added_to_hass()
|
||||
await entity.async_internal_added_to_hass()
|
||||
|
||||
data = await RestoreStateData.async_get_instance(hass)
|
||||
|
||||
@@ -206,7 +206,7 @@ async def test_state_saved_on_remove(hass):
|
||||
entity = RestoreEntity()
|
||||
entity.hass = hass
|
||||
entity.entity_id = 'input_boolean.b0'
|
||||
await entity.async_added_to_hass()
|
||||
await entity.async_internal_added_to_hass()
|
||||
|
||||
hass.states.async_set('input_boolean.b0', 'on')
|
||||
|
||||
@@ -215,7 +215,7 @@ async def test_state_saved_on_remove(hass):
|
||||
# No last states should currently be saved
|
||||
assert not data.last_states
|
||||
|
||||
await entity.async_will_remove_from_hass()
|
||||
await entity.async_remove()
|
||||
|
||||
# We should store the input boolean state when it is removed
|
||||
assert data.last_states['input_boolean.b0'].state.state == 'on'
|
||||
|
||||
Reference in New Issue
Block a user