2023-01-07 20:13:37 +00:00
|
|
|
"""Tests Starlink integration init/unload."""
|
2024-03-08 13:47:22 +00:00
|
|
|
|
2023-01-07 20:13:37 +00:00
|
|
|
from homeassistant.components.starlink.const import DOMAIN
|
|
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
|
|
from homeassistant.const import CONF_IP_ADDRESS
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
2024-03-18 15:18:32 +00:00
|
|
|
from .patchers import (
|
|
|
|
LOCATION_DATA_SUCCESS_PATCHER,
|
|
|
|
SLEEP_DATA_SUCCESS_PATCHER,
|
|
|
|
STATUS_DATA_SUCCESS_PATCHER,
|
|
|
|
)
|
2023-01-07 20:13:37 +00:00
|
|
|
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
|
|
|
|
|
|
async def test_successful_entry(hass: HomeAssistant) -> None:
|
|
|
|
"""Test configuring Starlink."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
data={CONF_IP_ADDRESS: "1.2.3.4:0000"},
|
|
|
|
)
|
|
|
|
|
2024-03-25 23:02:16 +00:00
|
|
|
with (
|
|
|
|
STATUS_DATA_SUCCESS_PATCHER,
|
|
|
|
LOCATION_DATA_SUCCESS_PATCHER,
|
|
|
|
SLEEP_DATA_SUCCESS_PATCHER,
|
|
|
|
):
|
2023-01-07 20:13:37 +00:00
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
await hass.config_entries.async_setup(entry.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
2024-04-05 15:37:00 +00:00
|
|
|
assert entry.state is ConfigEntryState.LOADED
|
2023-01-07 20:13:37 +00:00
|
|
|
assert entry.entry_id in hass.data[DOMAIN]
|
|
|
|
|
|
|
|
|
|
|
|
async def test_unload_entry(hass: HomeAssistant) -> None:
|
|
|
|
"""Test removing Starlink."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
data={CONF_IP_ADDRESS: "1.2.3.4:0000"},
|
|
|
|
)
|
|
|
|
|
2024-03-25 23:02:16 +00:00
|
|
|
with (
|
|
|
|
STATUS_DATA_SUCCESS_PATCHER,
|
|
|
|
LOCATION_DATA_SUCCESS_PATCHER,
|
|
|
|
SLEEP_DATA_SUCCESS_PATCHER,
|
|
|
|
):
|
2023-01-07 20:13:37 +00:00
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
await hass.config_entries.async_setup(entry.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert await hass.config_entries.async_unload(entry.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert entry.state is ConfigEntryState.NOT_LOADED
|
|
|
|
assert entry.entry_id not in hass.data[DOMAIN]
|