hass-core/tests/components/starlink/test_init.py
Jack Boswell 8a6bde1191
Add Starlink device tracker (#91445)
* Fetch location data and redact in diagnostics

* Implement device tracker

* Fix failing tests

* Update starlink-grpc-core

* Update coveragerc

* Hardcode GPS source type

* Use translations

* Move DEVICE_TRACKERS a little higher in the file

* Separate status and location check try/catches

* Revert "Separate status and location check try/catches"

This reverts commit 7628ec62f6.
2023-08-19 11:36:23 +02:00

46 lines
1.5 KiB
Python

"""Tests Starlink integration init/unload."""
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
from .patchers import LOCATION_DATA_SUCCESS_PATCHER, STATUS_DATA_SUCCESS_PATCHER
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"},
)
with STATUS_DATA_SUCCESS_PATCHER, LOCATION_DATA_SUCCESS_PATCHER:
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert entry.state == ConfigEntryState.LOADED
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"},
)
with STATUS_DATA_SUCCESS_PATCHER, LOCATION_DATA_SUCCESS_PATCHER:
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]