mirror of
https://github.com/elisspace/core.git
synced 2026-09-28 21:39:55 +00:00
Simplify unifi cleanup logic (#65345)
This commit is contained in:
@@ -18,7 +18,7 @@ from homeassistant.components.unifi.const import (
|
||||
DOMAIN as UNIFI_DOMAIN,
|
||||
)
|
||||
from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_UNAVAILABLE
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .test_controller import ENTRY_CONFIG, setup_unifi_integration
|
||||
@@ -317,49 +317,6 @@ async def test_remove_clients(
|
||||
assert hass.states.get("device_tracker.client_2")
|
||||
|
||||
|
||||
async def test_remove_client_but_keep_device_entry(
|
||||
hass, aioclient_mock, mock_unifi_websocket, mock_device_registry
|
||||
):
|
||||
"""Test that unifi entity base remove config entry id from a multi integration device registry entry."""
|
||||
client_1 = {
|
||||
"essid": "ssid",
|
||||
"hostname": "client_1",
|
||||
"is_wired": False,
|
||||
"last_seen": 1562600145,
|
||||
"mac": "00:00:00:00:00:01",
|
||||
}
|
||||
await setup_unifi_integration(hass, aioclient_mock, clients_response=[client_1])
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id="other",
|
||||
connections={("mac", "00:00:00:00:00:01")},
|
||||
)
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
other_entity = entity_registry.async_get_or_create(
|
||||
TRACKER_DOMAIN,
|
||||
"other",
|
||||
"unique_id",
|
||||
device_id=device_entry.id,
|
||||
)
|
||||
assert len(device_entry.config_entries) == 3
|
||||
|
||||
mock_unifi_websocket(
|
||||
data={
|
||||
"meta": {"message": MESSAGE_CLIENT_REMOVED},
|
||||
"data": [client_1],
|
||||
}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 0
|
||||
|
||||
device_entry = device_registry.async_get(other_entity.device_id)
|
||||
assert len(device_entry.config_entries) == 2
|
||||
|
||||
|
||||
async def test_controller_state_change(
|
||||
hass, aioclient_mock, mock_unifi_websocket, mock_device_registry
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user