mirror of https://github.com/home-assistant/core
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""Tests for TP-Link Omada integration init."""
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from homeassistant.components.tplink_omada.const import DOMAIN
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import device_registry as dr
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
MOCK_ENTRY_DATA = {
|
|
"host": "https://fake.omada.host",
|
|
"verify_ssl": True,
|
|
"site": "SiteId",
|
|
"username": "test-username",
|
|
"password": "test-password",
|
|
}
|
|
|
|
|
|
async def test_missing_devices_removed_at_startup(
|
|
hass: HomeAssistant,
|
|
device_registry: dr.DeviceRegistry,
|
|
mock_omada_client: MagicMock,
|
|
) -> None:
|
|
"""Test missing devices are removed at startup."""
|
|
mock_config_entry = MockConfigEntry(
|
|
title="Test Omada Controller",
|
|
domain=DOMAIN,
|
|
data=dict(MOCK_ENTRY_DATA),
|
|
unique_id="12345",
|
|
)
|
|
mock_config_entry.add_to_hass(hass)
|
|
|
|
device_entry = device_registry.async_get_or_create(
|
|
config_entry_id=mock_config_entry.entry_id,
|
|
identifiers={(DOMAIN, "AA:BB:CC:DD:EE:FF")},
|
|
manufacturer="TPLink",
|
|
name="Old Device",
|
|
model="Some old model",
|
|
)
|
|
|
|
assert device_registry.async_get(device_entry.id) == device_entry
|
|
|
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
assert device_registry.async_get(device_entry.id) is None
|