Make DeviceRegistry.async_get_device connections arg optional (#44897)
* Make async_get_device connections Optional, default None * Remove unnecessary async_get_device connections arg usages Some of these were using an incorrect collection type, which didn't cause issues mostly just due to luck.
This commit is contained in:
parent
751ac0b955
commit
2fb3be50ab
57 changed files with 181 additions and 232 deletions
|
@ -229,8 +229,8 @@ async def test_removing_config_entries(hass, registry, update_events):
|
|||
assert entry2.config_entries == {"123", "456"}
|
||||
|
||||
registry.async_clear_config_entry("123")
|
||||
entry = registry.async_get_device({("bridgeid", "0123")}, set())
|
||||
entry3_removed = registry.async_get_device({("bridgeid", "4567")}, set())
|
||||
entry = registry.async_get_device({("bridgeid", "0123")})
|
||||
entry3_removed = registry.async_get_device({("bridgeid", "4567")})
|
||||
|
||||
assert entry.config_entries == {"456"}
|
||||
assert entry3_removed is None
|
||||
|
@ -336,7 +336,7 @@ async def test_removing_area_id(registry):
|
|||
entry_w_area = registry.async_update_device(entry.id, area_id="12345A")
|
||||
|
||||
registry.async_clear_area_id("12345A")
|
||||
entry_wo_area = registry.async_get_device({("bridgeid", "0123")}, set())
|
||||
entry_wo_area = registry.async_get_device({("bridgeid", "0123")})
|
||||
|
||||
assert not entry_wo_area.area_id
|
||||
assert entry_w_area != entry_wo_area
|
||||
|
@ -366,7 +366,7 @@ async def test_deleted_device_removing_area_id(registry):
|
|||
)
|
||||
assert entry.id == entry2.id
|
||||
|
||||
entry_wo_area = registry.async_get_device({("bridgeid", "0123")}, set())
|
||||
entry_wo_area = registry.async_get_device({("bridgeid", "0123")})
|
||||
|
||||
assert not entry_wo_area.area_id
|
||||
assert entry_w_area != entry_wo_area
|
||||
|
@ -505,9 +505,9 @@ async def test_loading_saving_data(hass, registry):
|
|||
assert list(registry.devices) == list(registry2.devices)
|
||||
assert list(registry.deleted_devices) == list(registry2.deleted_devices)
|
||||
|
||||
new_via = registry2.async_get_device({("hue", "0123")}, set())
|
||||
new_light = registry2.async_get_device({("hue", "456")}, set())
|
||||
new_light4 = registry2.async_get_device({("hue", "abc")}, set())
|
||||
new_via = registry2.async_get_device({("hue", "0123")})
|
||||
new_light = registry2.async_get_device({("hue", "456")})
|
||||
new_light4 = registry2.async_get_device({("hue", "abc")})
|
||||
|
||||
assert orig_via == new_via
|
||||
assert orig_light == new_light
|
||||
|
@ -597,11 +597,11 @@ async def test_update(registry):
|
|||
assert updated_entry.via_device_id == "98765B"
|
||||
assert updated_entry.disabled_by == "user"
|
||||
|
||||
assert registry.async_get_device({("hue", "456")}, {}) is None
|
||||
assert registry.async_get_device({("bla", "123")}, {}) is None
|
||||
assert registry.async_get_device({("hue", "456")}) is None
|
||||
assert registry.async_get_device({("bla", "123")}) is None
|
||||
|
||||
assert registry.async_get_device({("hue", "654")}, {}) == updated_entry
|
||||
assert registry.async_get_device({("bla", "321")}, {}) == updated_entry
|
||||
assert registry.async_get_device({("hue", "654")}) == updated_entry
|
||||
assert registry.async_get_device({("bla", "321")}) == updated_entry
|
||||
|
||||
assert (
|
||||
registry.async_get_device(
|
||||
|
@ -652,7 +652,7 @@ async def test_update_remove_config_entries(hass, registry, update_events):
|
|||
assert updated_entry.config_entries == {"456"}
|
||||
assert removed_entry is None
|
||||
|
||||
removed_entry = registry.async_get_device({("bridgeid", "4567")}, set())
|
||||
removed_entry = registry.async_get_device({("bridgeid", "4567")})
|
||||
|
||||
assert removed_entry is None
|
||||
|
||||
|
@ -728,10 +728,10 @@ async def test_cleanup_device_registry(hass, registry):
|
|||
|
||||
device_registry.async_cleanup(hass, registry, ent_reg)
|
||||
|
||||
assert registry.async_get_device({("hue", "d1")}, set()) is not None
|
||||
assert registry.async_get_device({("hue", "d2")}, set()) is not None
|
||||
assert registry.async_get_device({("hue", "d3")}, set()) is not None
|
||||
assert registry.async_get_device({("something", "d4")}, set()) is None
|
||||
assert registry.async_get_device({("hue", "d1")}) is not None
|
||||
assert registry.async_get_device({("hue", "d2")}) is not None
|
||||
assert registry.async_get_device({("hue", "d3")}) is not None
|
||||
assert registry.async_get_device({("something", "d4")}) is None
|
||||
|
||||
|
||||
async def test_cleanup_startup(hass):
|
||||
|
|
|
@ -747,7 +747,7 @@ async def test_device_info_called(hass):
|
|||
|
||||
assert len(hass.states.async_entity_ids()) == 2
|
||||
|
||||
device = registry.async_get_device({("hue", "1234")}, set())
|
||||
device = registry.async_get_device({("hue", "1234")})
|
||||
assert device is not None
|
||||
assert device.identifiers == {("hue", "1234")}
|
||||
assert device.connections == {("mac", "abcd")}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue