Delete devices / entities when we remove a config entry. (#23983)
* Remove device when last config entry removed * Remove entities when config entry removed * Update tests to use new behaviour
This commit is contained in:
1 parent
d7d83c683d
commit
f991ec15f2
5 files changed
+27
-13
No files matched your search
@@ -211,10 +211,10 @@ async def test_removing_config_entries(hass, registry, update_events):
|
||||
|
||||
registry.async_clear_config_entry('123')
|
||||
entry = registry.async_get_device({('bridgeid', '0123')}, set())
|
||||
entry3 = registry.async_get_device({('bridgeid', '4567')}, set())
|
||||
entry3_removed = registry.async_get_device({('bridgeid', '4567')}, set())
|
||||
|
||||
assert entry.config_entries == {'456'}
|
||||
assert entry3.config_entries == set()
|
||||
assert entry3_removed is None
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -227,7 +227,7 @@ async def test_removing_config_entries(hass, registry, update_events):
|
||||
assert update_events[2]['device_id'] == entry3.id
|
||||
assert update_events[3]['action'] == 'update'
|
||||
assert update_events[3]['device_id'] == entry.id
|
||||
assert update_events[4]['action'] == 'update'
|
||||
assert update_events[4]['action'] == 'remove'
|
||||
assert update_events[4]['device_id'] == entry3.id
|
||||
|
||||
|
||||
|
||||
@@ -213,15 +213,14 @@ async def test_removing_config_entry_id(hass, registry, update_events):
|
||||
assert entry.config_entry_id == 'mock-id-1'
|
||||
registry.async_clear_config_entry('mock-id-1')
|
||||
|
||||
entry = registry.entities[entry.entity_id]
|
||||
assert entry.config_entry_id is None
|
||||
assert not registry.entities
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(update_events) == 2
|
||||
assert update_events[0]['action'] == 'create'
|
||||
assert update_events[0]['entity_id'] == entry.entity_id
|
||||
assert update_events[1]['action'] == 'update'
|
||||
assert update_events[1]['action'] == 'remove'
|
||||
assert update_events[1]['entity_id'] == entry.entity_id
|
||||
|
||||
|
||||
|
||||
@@ -261,9 +261,9 @@ async def test_remove_entry(hass, manager):
|
||||
# Just Group all_lights
|
||||
assert len(hass.states.async_all()) == 1
|
||||
|
||||
# Check that entity registry entry no longer references config_entry_id
|
||||
entity_entry = list(ent_reg.entities.values())[0]
|
||||
assert entity_entry.config_entry_id is None
|
||||
# Check that entity registry entry has been removed
|
||||
entity_entry_list = list(ent_reg.entities.values())
|
||||
assert not entity_entry_list
|
||||
|
||||
|
||||
async def test_remove_entry_handles_callback_error(hass, manager):
|
||||
|
||||
Reference in new issue
Block a user