Refactor DirecTV Integration to Async (#33114)
* switch to directv==0.1.1 * work on directv async. * Update const.py * Update __init__.py * Update media_player.py * Update __init__.py * Update __init__.py * Update __init__.py * Update media_player.py * Update test_config_flow.py * Update media_player.py * Update media_player.py * work on tests and coverage. * Update __init__.py * Update __init__.py * squash.
This commit is contained in:
1 parent
3566803d2e
commit
b892dbc6ea
19 files changed
+749
-845
No files matched your search
@@ -1,7 +1,4 @@
|
||||
"""Tests for the Roku integration."""
|
||||
from asynctest import patch
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
"""Tests for the DirecTV integration."""
|
||||
from homeassistant.components.directv.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
@@ -9,34 +6,36 @@ from homeassistant.config_entries import (
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.components.directv import MockDirectvClass, setup_integration
|
||||
from tests.components.directv import MOCK_CONFIG, mock_connection, setup_integration
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
|
||||
async def test_config_entry_not_ready(hass: HomeAssistantType) -> None:
|
||||
async def test_setup(
|
||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test the DirecTV setup from configuration."""
|
||||
mock_connection(aioclient_mock)
|
||||
assert await async_setup_component(hass, DOMAIN, MOCK_CONFIG)
|
||||
|
||||
|
||||
async def test_config_entry_not_ready(
|
||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
||||
) -> 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)
|
||||
entry = await setup_integration(hass, aioclient_mock, setup_error=True)
|
||||
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
|
||||
|
||||
async def test_unload_config_entry(hass: HomeAssistantType) -> None:
|
||||
async def test_unload_config_entry(
|
||||
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
|
||||
) -> 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)
|
||||
entry = await setup_integration(hass, aioclient_mock)
|
||||
|
||||
assert entry.entry_id in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_LOADED
|
||||
|
||||
Reference in new issue
Block a user