mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Make device entry disabled by an enum (#60239)
This commit is contained in:
@@ -176,7 +176,7 @@ async def test_loading_from_storage(hass, hass_storage):
|
||||
"config_entries": ["1234"],
|
||||
"configuration_url": None,
|
||||
"connections": [["Zigbee", "01.23.45.67.89"]],
|
||||
"disabled_by": device_registry.DISABLED_USER,
|
||||
"disabled_by": device_registry.DeviceEntryDisabler.USER,
|
||||
"entry_type": device_registry.DeviceEntryType.SERVICE,
|
||||
"id": "abcdefghijklm",
|
||||
"identifiers": [["serial", "12:34:56:AB:CD:EF"]],
|
||||
@@ -216,7 +216,7 @@ async def test_loading_from_storage(hass, hass_storage):
|
||||
assert entry.area_id == "12345A"
|
||||
assert entry.name_by_user == "Test Friendly Name"
|
||||
assert entry.entry_type is device_registry.DeviceEntryType.SERVICE
|
||||
assert entry.disabled_by == device_registry.DISABLED_USER
|
||||
assert entry.disabled_by is device_registry.DeviceEntryDisabler.USER
|
||||
assert isinstance(entry.config_entries, set)
|
||||
assert isinstance(entry.connections, set)
|
||||
assert isinstance(entry.identifiers, set)
|
||||
@@ -574,7 +574,7 @@ async def test_loading_saving_data(hass, registry, area_registry):
|
||||
manufacturer="manufacturer",
|
||||
model="light",
|
||||
via_device=("hue", "0123"),
|
||||
disabled_by=device_registry.DISABLED_USER,
|
||||
disabled_by=device_registry.DeviceEntryDisabler.USER,
|
||||
)
|
||||
|
||||
orig_light2 = registry.async_get_or_create(
|
||||
@@ -623,7 +623,7 @@ async def test_loading_saving_data(hass, registry, area_registry):
|
||||
manufacturer="manufacturer",
|
||||
model="light",
|
||||
via_device=("hue", "0123"),
|
||||
disabled_by=device_registry.DISABLED_USER,
|
||||
disabled_by=device_registry.DeviceEntryDisabler.USER,
|
||||
suggested_area="Kitchen",
|
||||
)
|
||||
|
||||
@@ -732,7 +732,7 @@ async def test_update(registry):
|
||||
name_by_user="Test Friendly Name",
|
||||
new_identifiers=new_identifiers,
|
||||
via_device_id="98765B",
|
||||
disabled_by=device_registry.DISABLED_USER,
|
||||
disabled_by=device_registry.DeviceEntryDisabler.USER,
|
||||
)
|
||||
|
||||
assert mock_save.call_count == 1
|
||||
@@ -743,7 +743,7 @@ async def test_update(registry):
|
||||
assert updated_entry.name_by_user == "Test Friendly Name"
|
||||
assert updated_entry.identifiers == new_identifiers
|
||||
assert updated_entry.via_device_id == "98765B"
|
||||
assert updated_entry.disabled_by == device_registry.DISABLED_USER
|
||||
assert updated_entry.disabled_by is device_registry.DeviceEntryDisabler.USER
|
||||
|
||||
assert registry.async_get_device({("hue", "456")}) is None
|
||||
assert registry.async_get_device({("bla", "123")}) is None
|
||||
@@ -1307,7 +1307,7 @@ async def test_disable_config_entry_disables_devices(hass, registry):
|
||||
entry2 = registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(device_registry.CONNECTION_NETWORK_MAC, "34:56:AB:CD:EF:12")},
|
||||
disabled_by=device_registry.DISABLED_USER,
|
||||
disabled_by=device_registry.DeviceEntryDisabler.USER,
|
||||
)
|
||||
|
||||
assert not entry1.disabled
|
||||
@@ -1320,10 +1320,10 @@ async def test_disable_config_entry_disables_devices(hass, registry):
|
||||
|
||||
entry1 = registry.async_get(entry1.id)
|
||||
assert entry1.disabled
|
||||
assert entry1.disabled_by == device_registry.DISABLED_CONFIG_ENTRY
|
||||
assert entry1.disabled_by is device_registry.DeviceEntryDisabler.CONFIG_ENTRY
|
||||
entry2 = registry.async_get(entry2.id)
|
||||
assert entry2.disabled
|
||||
assert entry2.disabled_by == device_registry.DISABLED_USER
|
||||
assert entry2.disabled_by is device_registry.DeviceEntryDisabler.USER
|
||||
|
||||
await hass.config_entries.async_set_disabled_by(config_entry.entry_id, None)
|
||||
await hass.async_block_till_done()
|
||||
@@ -1332,7 +1332,7 @@ async def test_disable_config_entry_disables_devices(hass, registry):
|
||||
assert not entry1.disabled
|
||||
entry2 = registry.async_get(entry2.id)
|
||||
assert entry2.disabled
|
||||
assert entry2.disabled_by == device_registry.DISABLED_USER
|
||||
assert entry2.disabled_by is device_registry.DeviceEntryDisabler.USER
|
||||
|
||||
|
||||
async def test_only_disable_device_if_all_config_entries_are_disabled(hass, registry):
|
||||
@@ -1368,7 +1368,7 @@ async def test_only_disable_device_if_all_config_entries_are_disabled(hass, regi
|
||||
|
||||
entry1 = registry.async_get(entry1.id)
|
||||
assert entry1.disabled
|
||||
assert entry1.disabled_by == device_registry.DISABLED_CONFIG_ENTRY
|
||||
assert entry1.disabled_by is device_registry.DeviceEntryDisabler.CONFIG_ENTRY
|
||||
|
||||
await hass.config_entries.async_set_disabled_by(config_entry1.entry_id, None)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
Reference in New Issue
Block a user