Allow sw_version update of a device registry entry. (#32630)

pull/32691/head
Alexei Chetroi 2020-03-11 12:31:02 -04:00 committed by GitHub
parent ffe8b94d75
commit 440c837eb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -155,6 +155,7 @@ class DeviceRegistry:
name=_UNDEF,
name_by_user=_UNDEF,
new_identifiers=_UNDEF,
sw_version=_UNDEF,
via_device_id=_UNDEF,
remove_config_entry_id=_UNDEF,
):
@ -165,6 +166,7 @@ class DeviceRegistry:
name=name,
name_by_user=name_by_user,
new_identifiers=new_identifiers,
sw_version=sw_version,
via_device_id=via_device_id,
remove_config_entry_id=remove_config_entry_id,
)

View File

@ -480,3 +480,21 @@ async def test_loading_race_condition(hass):
mock_load.assert_called_once_with()
assert results[0] == results[1]
async def test_update_sw_version(registry):
"""Verify that we can update software version of a device."""
entry = registry.async_get_or_create(
config_entry_id="1234",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bla", "123")},
)
assert not entry.sw_version
sw_version = "0x20020263"
with patch.object(registry, "async_schedule_save") as mock_save:
updated_entry = registry.async_update_device(entry.id, sw_version=sw_version)
assert mock_save.call_count == 1
assert updated_entry != entry
assert updated_entry.sw_version == sw_version