Add core APIs to migrate device identifiers and entity unique_id (#23481)
* Add device identifiers migration * Add entity unique_id migration * Update per arch issue * Move to existing update methods
This commit is contained in:
1 parent
41f0066e76
commit
cfaaae661a
4 files changed
+61
-9
No files matched your search
@@ -361,17 +361,25 @@ async def test_update(registry):
|
||||
config_entry_id='1234',
|
||||
connections={
|
||||
(device_registry.CONNECTION_NETWORK_MAC, '12:34:56:AB:CD:EF')
|
||||
})
|
||||
|
||||
},
|
||||
identifiers={('hue', '456'), ('bla', '123')})
|
||||
new_identifiers = {
|
||||
('hue', '654'),
|
||||
('bla', '321')
|
||||
}
|
||||
assert not entry.area_id
|
||||
assert not entry.name_by_user
|
||||
|
||||
updated_entry = registry.async_update_device(
|
||||
entry.id, area_id='12345A', name_by_user='Test Friendly Name')
|
||||
with patch.object(registry, 'async_schedule_save') as mock_save:
|
||||
updated_entry = registry.async_update_device(
|
||||
entry.id, area_id='12345A', name_by_user='Test Friendly Name',
|
||||
new_identifiers=new_identifiers)
|
||||
|
||||
assert mock_save.call_count == 1
|
||||
assert updated_entry != entry
|
||||
assert updated_entry.area_id == '12345A'
|
||||
assert updated_entry.name_by_user == 'Test Friendly Name'
|
||||
assert updated_entry.identifiers == new_identifiers
|
||||
|
||||
|
||||
async def test_loading_race_condition(hass):
|
||||
|
||||
Reference in new issue
Block a user