2020-03-31 17:35:32 -05:00
|
|
|
"""Tests for the DirecTV integration."""
|
2020-03-11 14:28:38 -05:00
|
|
|
from homeassistant.components.directv.const import DOMAIN
|
2021-05-20 20:19:20 +03:00
|
|
|
from homeassistant.config_entries import ConfigEntryState
|
2021-04-22 03:53:06 +02:00
|
|
|
from homeassistant.core import HomeAssistant
|
2020-03-11 14:28:38 -05:00
|
|
|
|
2022-09-19 09:31:57 +02:00
|
|
|
from . import setup_integration
|
|
|
|
|
2020-03-31 17:35:32 -05:00
|
|
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
2020-03-11 14:28:38 -05:00
|
|
|
|
|
|
|
|
2020-03-31 17:35:32 -05:00
|
|
|
async def test_config_entry_not_ready(
|
2021-04-22 03:53:06 +02:00
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
2020-03-31 17:35:32 -05:00
|
|
|
) -> None:
|
2020-03-11 14:28:38 -05:00
|
|
|
"""Test the DirecTV configuration entry not ready."""
|
2020-03-31 17:35:32 -05:00
|
|
|
entry = await setup_integration(hass, aioclient_mock, setup_error=True)
|
2020-03-11 14:28:38 -05:00
|
|
|
|
2021-05-20 20:19:20 +03:00
|
|
|
assert entry.state is ConfigEntryState.SETUP_RETRY
|
2020-03-11 14:28:38 -05:00
|
|
|
|
|
|
|
|
2020-03-31 17:35:32 -05:00
|
|
|
async def test_unload_config_entry(
|
2021-04-22 03:53:06 +02:00
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
2020-03-31 17:35:32 -05:00
|
|
|
) -> None:
|
2020-03-11 14:28:38 -05:00
|
|
|
"""Test the DirecTV configuration entry unloading."""
|
2020-03-31 17:35:32 -05:00
|
|
|
entry = await setup_integration(hass, aioclient_mock)
|
2020-03-11 14:28:38 -05:00
|
|
|
|
|
|
|
assert entry.entry_id in hass.data[DOMAIN]
|
2021-05-20 20:19:20 +03:00
|
|
|
assert entry.state is ConfigEntryState.LOADED
|
2020-03-11 14:28:38 -05:00
|
|
|
|
|
|
|
await hass.config_entries.async_unload(entry.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert entry.entry_id not in hass.data[DOMAIN]
|
2021-05-20 20:19:20 +03:00
|
|
|
assert entry.state is ConfigEntryState.NOT_LOADED
|