mirror of
https://github.com/home-assistant/core.git
synced 2025-08-19 18:30:05 +00:00
Add device registry cleanup to github (#64380)
This commit is contained in:
31
tests/components/github/test_init.py
Normal file
31
tests/components/github/test_init.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Test the GitHub init file."""
|
||||
from pytest import LogCaptureFixture
|
||||
|
||||
from homeassistant.components.github import async_cleanup_device_registry
|
||||
from homeassistant.components.github.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry, mock_device_registry
|
||||
|
||||
|
||||
async def test_device_registry_cleanup(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
caplog: LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that we remove untracked repositories from the decvice registry."""
|
||||
registry = mock_device_registry(hass)
|
||||
|
||||
device = registry.async_get_or_create(
|
||||
identifiers={(DOMAIN, "test/repository")},
|
||||
config_entry_id=mock_config_entry.entry_id,
|
||||
)
|
||||
|
||||
assert registry.async_get_device({(DOMAIN, "test/repository")}) == device
|
||||
await async_cleanup_device_registry(hass, mock_config_entry)
|
||||
|
||||
assert (
|
||||
f"Unlinking device {device.id} for untracked repository test/repository from config entry {mock_config_entry.entry_id}"
|
||||
in caplog.text
|
||||
)
|
||||
assert registry.async_get_device({(DOMAIN, "test/repository")}) is None
|
Reference in New Issue
Block a user