mirror of
https://github.com/home-assistant/core.git
synced 2026-05-19 06:50:15 +01:00
d11d88bb76
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
"""Test the Kiosker integration initialization."""
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
from homeassistant.components.kiosker.const import DOMAIN
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import device_registry as dr
|
|
|
|
from . import setup_integration
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def test_async_setup_entry(
|
|
hass: HomeAssistant,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_kiosker_api: MagicMock,
|
|
) -> None:
|
|
"""Test a successful setup entry and unload."""
|
|
await setup_integration(hass, mock_config_entry)
|
|
assert mock_config_entry.state is ConfigEntryState.LOADED
|
|
|
|
assert 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_async_setup_entry_failure(
|
|
hass: HomeAssistant,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_kiosker_api: MagicMock,
|
|
) -> None:
|
|
"""Test an unsuccessful setup entry."""
|
|
mock_kiosker_api.status.side_effect = Exception("Connection failed")
|
|
|
|
await setup_integration(hass, mock_config_entry)
|
|
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
|
|
|
|
|
|
async def test_device_info(
|
|
hass: HomeAssistant,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_kiosker_api: MagicMock,
|
|
device_registry: dr.DeviceRegistry,
|
|
snapshot: SnapshotAssertion,
|
|
) -> None:
|
|
"""Test device registry integration."""
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
device_entry = device_registry.async_get_device(
|
|
identifiers={(DOMAIN, "A98BE1CE-5FE7-4A8D-B2C3-123456789ABC")}
|
|
)
|
|
assert device_entry is not None
|
|
assert device_entry == snapshot
|