mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Allow updating of via_device in device registry (#24921)
* Allow updating of via_device in device registry * Added test
This commit is contained in:
parent
3c487928d4
commit
a491f97eb9
@ -138,12 +138,12 @@ class DeviceRegistry:
|
||||
def async_update_device(
|
||||
self, device_id, *, area_id=_UNDEF,
|
||||
name=_UNDEF, name_by_user=_UNDEF,
|
||||
new_identifiers=_UNDEF):
|
||||
new_identifiers=_UNDEF, via_device_id=_UNDEF):
|
||||
"""Update properties of a device."""
|
||||
return self._async_update_device(
|
||||
device_id, area_id=area_id,
|
||||
name=name, name_by_user=name_by_user,
|
||||
new_identifiers=new_identifiers)
|
||||
new_identifiers=new_identifiers, via_device_id=via_device_id)
|
||||
|
||||
@callback
|
||||
def _async_update_device(self, device_id, *, add_config_entry_id=_UNDEF,
|
||||
|
@ -395,7 +395,7 @@ async def test_format_mac(registry):
|
||||
|
||||
|
||||
async def test_update(registry):
|
||||
"""Verify that we can update area_id of a device."""
|
||||
"""Verify that we can update some attributes of a device."""
|
||||
entry = registry.async_get_or_create(
|
||||
config_entry_id='1234',
|
||||
connections={
|
||||
@ -412,13 +412,14 @@ async def test_update(registry):
|
||||
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)
|
||||
new_identifiers=new_identifiers, via_device_id='98765B')
|
||||
|
||||
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
|
||||
assert updated_entry.via_device_id == '98765B'
|
||||
|
||||
|
||||
async def test_loading_race_condition(hass):
|
||||
|
Loading…
x
Reference in New Issue
Block a user