1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 00:20:30 +01:00
Files
core/tests/components/trmnl/test_init.py
2026-03-14 16:17:19 +01:00

48 lines
1.4 KiB
Python

"""Test the TRMNL initialization."""
from unittest.mock import AsyncMock
from syrupy.assertion import SnapshotAssertion
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from . import setup_integration
from tests.common import MockConfigEntry
async def test_load_unload_entry(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_trmnl_client: AsyncMock,
) -> None:
"""Test loading and unloading a config entry."""
await setup_integration(hass, mock_config_entry)
assert mock_config_entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
async def test_device(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
mock_config_entry: MockConfigEntry,
mock_trmnl_client: AsyncMock,
snapshot: SnapshotAssertion,
) -> None:
"""Test the TRMNL device."""
await setup_integration(hass, mock_config_entry)
device = device_registry.async_get_device(
connections={(CONNECTION_NETWORK_MAC, "B0:A6:04:AA:BB:CC")}
)
assert device
assert device == snapshot