Add config flow to directv (#32162)
* initial work on config flow. * more work on config flow. * work on config flow and add tests. other cleanup. * cleanup tests. * fix test. * isort * Update .coveragerc * Update test_init.py * Update test_init.py * Update test_init.py * Update test_config_flow.py * Update test_config_flow.py * Update test_config_flow.py * correct upnp serial format. * improve config flow coverage. * review tweaks. * further review tweaks * simplify dtv data gathering job * lint * black * Update test_init.py * Update test_init.py * Simplify exception handling. * Simplify exception handling. * Update media_player.py * Update test_media_player.py * Update test_media_player.py * Update test_media_player.py * Update test_media_player.py * Update test_media_player.py * fix failing test. * restore change made during debug. * isort. Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
1 parent
c9a9bd16fe
commit
bb666b9ac6
14 files changed
+1062
-492
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""Tests for the Roku integration."""
|
||||
from asynctest import patch
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from homeassistant.components.directv.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
|
||||
from tests.components.directv import MockDirectvClass, setup_integration
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
|
||||
async def test_config_entry_not_ready(hass: HomeAssistantType) -> None:
|
||||
"""Test the DirecTV configuration entry not ready."""
|
||||
with patch(
|
||||
"homeassistant.components.directv.DIRECTV", new=MockDirectvClass,
|
||||
), patch(
|
||||
"homeassistant.components.directv.DIRECTV.get_locations",
|
||||
side_effect=RequestException,
|
||||
):
|
||||
entry = await setup_integration(hass)
|
||||
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
|
||||
|
||||
async def test_unload_config_entry(hass: HomeAssistantType) -> None:
|
||||
"""Test the DirecTV configuration entry unloading."""
|
||||
with patch(
|
||||
"homeassistant.components.directv.DIRECTV", new=MockDirectvClass,
|
||||
), patch(
|
||||
"homeassistant.components.directv.media_player.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
entry = await setup_integration(hass)
|
||||
|
||||
assert entry.entry_id in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_LOADED
|
||||
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.entry_id not in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
Reference in new issue
Block a user