Add type hints to integration tests (a) (#87684)
* Add type hints to accuweather tests * Adjust a** components * Adjust aiohttp_client * ClientSessionGenerator/WebSocketGenerator
This commit is contained in:
parent
7665c89b83
commit
2545694d41
79 changed files with 720 additions and 425 deletions
|
@ -8,6 +8,7 @@ from homeassistant.components.airly import set_update_interval
|
|||
from homeassistant.components.airly.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
|
@ -19,9 +20,12 @@ from tests.common import (
|
|||
load_fixture,
|
||||
mock_device_registry,
|
||||
)
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
async def test_async_setup_entry(hass, aioclient_mock):
|
||||
async def test_async_setup_entry(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test a successful setup entry."""
|
||||
await init_integration(hass, aioclient_mock)
|
||||
|
||||
|
@ -31,7 +35,9 @@ async def test_async_setup_entry(hass, aioclient_mock):
|
|||
assert state.state == "4.37"
|
||||
|
||||
|
||||
async def test_config_not_ready(hass, aioclient_mock):
|
||||
async def test_config_not_ready(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test for setup failure if connection to Airly is missing."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -52,7 +58,9 @@ async def test_config_not_ready(hass, aioclient_mock):
|
|||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_config_without_unique_id(hass, aioclient_mock):
|
||||
async def test_config_without_unique_id(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test for setup entry without unique_id."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -72,7 +80,9 @@ async def test_config_without_unique_id(hass, aioclient_mock):
|
|||
assert entry.unique_id == "123-456"
|
||||
|
||||
|
||||
async def test_config_with_turned_off_station(hass, aioclient_mock):
|
||||
async def test_config_with_turned_off_station(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test for setup entry for a turned off measuring station."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -92,7 +102,9 @@ async def test_config_with_turned_off_station(hass, aioclient_mock):
|
|||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_update_interval(hass, aioclient_mock):
|
||||
async def test_update_interval(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test correct update interval when the number of configured instances changes."""
|
||||
REMAINING_REQUESTS = 15
|
||||
HEADERS = {
|
||||
|
@ -173,7 +185,9 @@ async def test_update_interval(hass, aioclient_mock):
|
|||
assert aioclient_mock.call_count == 5
|
||||
|
||||
|
||||
async def test_unload_entry(hass, aioclient_mock):
|
||||
async def test_unload_entry(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test successful unload of entry."""
|
||||
entry = await init_integration(hass, aioclient_mock)
|
||||
|
||||
|
@ -219,7 +233,9 @@ async def test_migrate_device_entry(hass, aioclient_mock, old_identifier):
|
|||
assert device_entry.id == migrated_device_entry.id
|
||||
|
||||
|
||||
async def test_remove_air_quality_entities(hass, aioclient_mock):
|
||||
async def test_remove_air_quality_entities(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test remove air_quality entities from registry."""
|
||||
registry = er.async_get(hass)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue