2020-03-31 22:35:32 +00:00
|
|
|
"""Tests for the DirecTV integration."""
|
2020-03-11 19:28:38 +00:00
|
|
|
from homeassistant.components.directv.const import DOMAIN
|
2021-05-20 17:19:20 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntryState
|
2021-04-22 01:53:06 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2020-03-11 19:28:38 +00:00
|
|
|
|
2020-10-29 08:51:22 +00:00
|
|
|
from tests.components.directv import setup_integration
|
2020-03-31 22:35:32 +00:00
|
|
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
2020-03-11 19:28:38 +00:00
|
|
|
|
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
|
|
|
|
|
2020-03-31 22:35:32 +00:00
|
|
|
async def test_config_entry_not_ready(
|
2021-04-22 01:53:06 +00:00
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
2020-03-31 22:35:32 +00:00
|
|
|
) -> None:
|
2020-03-11 19:28:38 +00:00
|
|
|
"""Test the DirecTV configuration entry not ready."""
|
2020-03-31 22:35:32 +00:00
|
|
|
entry = await setup_integration(hass, aioclient_mock, setup_error=True)
|
2020-03-11 19:28:38 +00:00
|
|
|
|
2021-05-20 17:19:20 +00:00
|
|
|
assert entry.state is ConfigEntryState.SETUP_RETRY
|
2020-03-11 19:28:38 +00:00
|
|
|
|
|
|
|
|
2020-03-31 22:35:32 +00:00
|
|
|
async def test_unload_config_entry(
|
2021-04-22 01:53:06 +00:00
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
2020-03-31 22:35:32 +00:00
|
|
|
) -> None:
|
2020-03-11 19:28:38 +00:00
|
|
|
"""Test the DirecTV configuration entry unloading."""
|
2020-03-31 22:35:32 +00:00
|
|
|
entry = await setup_integration(hass, aioclient_mock)
|
2020-03-11 19:28:38 +00:00
|
|
|
|
|
|
|
assert entry.entry_id in hass.data[DOMAIN]
|
2021-05-20 17:19:20 +00:00
|
|
|
assert entry.state is ConfigEntryState.LOADED
|
2020-03-11 19:28:38 +00: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 17:19:20 +00:00
|
|
|
assert entry.state is ConfigEntryState.NOT_LOADED
|