Use device registry CONNECTION_* constants (#49923)

This commit is contained in:
Ville Skyttä 2021-05-01 00:58:50 +03:00 committed by GitHub
parent 7ead482082
commit 77d5244577
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 195 additions and 84 deletions

View file

@ -382,7 +382,9 @@ async def help_test_discovery_removal(
await hass.async_block_till_done()
# Verify device and entity registry entries are created
device_entry = device_reg.async_get_device(set(), {("mac", config1[CONF_MAC])})
device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config1[CONF_MAC])}
)
assert device_entry is not None
entity_entry = entity_reg.async_get(f"{domain}.{entity_id}")
assert entity_entry is not None
@ -403,7 +405,9 @@ async def help_test_discovery_removal(
await hass.async_block_till_done()
# Verify entity registry entries are cleared
device_entry = device_reg.async_get_device(set(), {("mac", config2[CONF_MAC])})
device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config2[CONF_MAC])}
)
assert device_entry is not None
entity_entry = entity_reg.async_get(f"{domain}.{entity_id}")
assert entity_entry is None
@ -487,14 +491,18 @@ async def help_test_discovery_device_remove(
)
await hass.async_block_till_done()
device = device_reg.async_get_device(set(), {("mac", config[CONF_MAC])})
device = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config[CONF_MAC])}
)
assert device is not None
assert entity_reg.async_get_entity_id(domain, "tasmota", unique_id)
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{config[CONF_MAC]}/config", "")
await hass.async_block_till_done()
device = device_reg.async_get_device(set(), {("mac", config[CONF_MAC])})
device = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config[CONF_MAC])}
)
assert device is None
assert not entity_reg.async_get_entity_id(domain, "tasmota", unique_id)