Add type hints to integration tests (d-e) (#87699)
This commit is contained in:
parent
5e214f2e43
commit
3052de3e8e
81 changed files with 765 additions and 450 deletions
|
@ -1,5 +1,4 @@
|
|||
"""Test deCONZ component setup process."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.deconz import (
|
||||
|
@ -15,11 +14,13 @@ from homeassistant.components.deconz.const import (
|
|||
from homeassistant.components.deconz.errors import AuthenticationRequired, CannotConnect
|
||||
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .test_gateway import DECONZ_WEB_REQUEST, setup_deconz_integration
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
ENTRY1_HOST = "1.2.3.4"
|
||||
ENTRY1_PORT = 80
|
||||
|
@ -42,7 +43,9 @@ async def setup_entry(hass, entry):
|
|||
assert await async_setup_entry(hass, entry) is True
|
||||
|
||||
|
||||
async def test_setup_entry_successful(hass, aioclient_mock):
|
||||
async def test_setup_entry_successful(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test setup entry is successful."""
|
||||
config_entry = await setup_deconz_integration(hass, aioclient_mock)
|
||||
|
||||
|
@ -51,7 +54,7 @@ async def test_setup_entry_successful(hass, aioclient_mock):
|
|||
assert hass.data[DECONZ_DOMAIN][config_entry.entry_id].master
|
||||
|
||||
|
||||
async def test_setup_entry_fails_config_entry_not_ready(hass):
|
||||
async def test_setup_entry_fails_config_entry_not_ready(hass: HomeAssistant) -> None:
|
||||
"""Failed authentication trigger a reauthentication flow."""
|
||||
with patch(
|
||||
"homeassistant.components.deconz.get_deconz_session",
|
||||
|
@ -62,7 +65,7 @@ async def test_setup_entry_fails_config_entry_not_ready(hass):
|
|||
assert hass.data[DECONZ_DOMAIN] == {}
|
||||
|
||||
|
||||
async def test_setup_entry_fails_trigger_reauth_flow(hass):
|
||||
async def test_setup_entry_fails_trigger_reauth_flow(hass: HomeAssistant) -> None:
|
||||
"""Failed authentication trigger a reauthentication flow."""
|
||||
with patch(
|
||||
"homeassistant.components.deconz.get_deconz_session",
|
||||
|
@ -74,7 +77,9 @@ async def test_setup_entry_fails_trigger_reauth_flow(hass):
|
|||
assert hass.data[DECONZ_DOMAIN] == {}
|
||||
|
||||
|
||||
async def test_setup_entry_multiple_gateways(hass, aioclient_mock):
|
||||
async def test_setup_entry_multiple_gateways(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test setup entry is successful with multiple gateways."""
|
||||
config_entry = await setup_deconz_integration(hass, aioclient_mock)
|
||||
aioclient_mock.clear_requests()
|
||||
|
@ -93,7 +98,9 @@ async def test_setup_entry_multiple_gateways(hass, aioclient_mock):
|
|||
assert not hass.data[DECONZ_DOMAIN][config_entry2.entry_id].master
|
||||
|
||||
|
||||
async def test_unload_entry(hass, aioclient_mock):
|
||||
async def test_unload_entry(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test being able to unload an entry."""
|
||||
config_entry = await setup_deconz_integration(hass, aioclient_mock)
|
||||
assert hass.data[DECONZ_DOMAIN]
|
||||
|
@ -102,7 +109,9 @@ async def test_unload_entry(hass, aioclient_mock):
|
|||
assert not hass.data[DECONZ_DOMAIN]
|
||||
|
||||
|
||||
async def test_unload_entry_multiple_gateways(hass, aioclient_mock):
|
||||
async def test_unload_entry_multiple_gateways(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test being able to unload an entry and master gateway gets moved."""
|
||||
config_entry = await setup_deconz_integration(hass, aioclient_mock)
|
||||
aioclient_mock.clear_requests()
|
||||
|
@ -124,7 +133,7 @@ async def test_unload_entry_multiple_gateways(hass, aioclient_mock):
|
|||
assert hass.data[DECONZ_DOMAIN][config_entry2.entry_id].master
|
||||
|
||||
|
||||
async def test_update_group_unique_id(hass):
|
||||
async def test_update_group_unique_id(hass: HomeAssistant) -> None:
|
||||
"""Test successful migration of entry data."""
|
||||
old_unique_id = "123"
|
||||
new_unique_id = "1234"
|
||||
|
@ -164,7 +173,7 @@ async def test_update_group_unique_id(hass):
|
|||
assert registry.async_get(f"{LIGHT_DOMAIN}.new").unique_id == f"{new_unique_id}-NEW"
|
||||
|
||||
|
||||
async def test_update_group_unique_id_no_legacy_group_id(hass):
|
||||
async def test_update_group_unique_id_no_legacy_group_id(hass: HomeAssistant) -> None:
|
||||
"""Test migration doesn't trigger without old legacy group id in entry data."""
|
||||
old_unique_id = "123"
|
||||
new_unique_id = "1234"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue