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:
epenet 2023-02-08 12:16:23 +01:00 committed by GitHub
parent 7665c89b83
commit 2545694d41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 720 additions and 425 deletions

View file

@ -16,6 +16,7 @@ from homeassistant.const import (
STATE_LOCKED,
STATE_ON,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.entity_registry import EntityRegistry
@ -33,9 +34,10 @@ from .mocks import (
)
from tests.common import MockConfigEntry
from tests.typing import WebSocketGenerator
async def test_august_api_is_failing(hass):
async def test_august_api_is_failing(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_RETRY when august api is failing."""
config_entry = MockConfigEntry(
@ -55,7 +57,7 @@ async def test_august_api_is_failing(hass):
assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_august_is_offline(hass):
async def test_august_is_offline(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_RETRY when august is offline."""
config_entry = MockConfigEntry(
@ -75,7 +77,7 @@ async def test_august_is_offline(hass):
assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_unlock_throws_august_api_http_error(hass):
async def test_unlock_throws_august_api_http_error(hass: HomeAssistant) -> None:
"""Test unlock throws correct error on http error."""
mocked_lock_detail = await _mock_operative_august_lock_detail(hass)
@ -101,7 +103,7 @@ async def test_unlock_throws_august_api_http_error(hass):
)
async def test_lock_throws_august_api_http_error(hass):
async def test_lock_throws_august_api_http_error(hass: HomeAssistant) -> None:
"""Test lock throws correct error on http error."""
mocked_lock_detail = await _mock_operative_august_lock_detail(hass)
@ -127,7 +129,7 @@ async def test_lock_throws_august_api_http_error(hass):
)
async def test_inoperative_locks_are_filtered_out(hass):
async def test_inoperative_locks_are_filtered_out(hass: HomeAssistant) -> None:
"""Ensure inoperative locks do not get setup."""
august_operative_lock = await _mock_operative_august_lock_detail(hass)
august_inoperative_lock = await _mock_inoperative_august_lock_detail(hass)
@ -143,7 +145,7 @@ async def test_inoperative_locks_are_filtered_out(hass):
assert lock_a6697750d607098bae8d6baa11ef8063_name.state == STATE_LOCKED
async def test_lock_has_doorsense(hass):
async def test_lock_has_doorsense(hass: HomeAssistant) -> None:
"""Check to see if a lock has doorsense."""
doorsenselock = await _mock_doorsense_enabled_august_lock_detail(hass)
nodoorsenselock = await _mock_doorsense_missing_august_lock_detail(hass)
@ -159,7 +161,7 @@ async def test_lock_has_doorsense(hass):
assert binary_sensor_missing_doorsense_id_name_open is None
async def test_auth_fails(hass):
async def test_auth_fails(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_ERROR when auth fails."""
config_entry = MockConfigEntry(
@ -184,7 +186,7 @@ async def test_auth_fails(hass):
assert flows[0]["step_id"] == "reauth_validate"
async def test_bad_password(hass):
async def test_bad_password(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_ERROR when the password has been changed."""
config_entry = MockConfigEntry(
@ -211,7 +213,7 @@ async def test_bad_password(hass):
assert flows[0]["step_id"] == "reauth_validate"
async def test_http_failure(hass):
async def test_http_failure(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_RETRY when august is offline."""
config_entry = MockConfigEntry(
@ -234,7 +236,7 @@ async def test_http_failure(hass):
assert hass.config_entries.flow.async_progress() == []
async def test_unknown_auth_state(hass):
async def test_unknown_auth_state(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_ERROR when august is in an unknown auth state."""
config_entry = MockConfigEntry(
@ -259,7 +261,7 @@ async def test_unknown_auth_state(hass):
assert flows[0]["step_id"] == "reauth_validate"
async def test_requires_validation_state(hass):
async def test_requires_validation_state(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_ERROR when august requires validation."""
config_entry = MockConfigEntry(
@ -285,7 +287,7 @@ async def test_requires_validation_state(hass):
assert hass.config_entries.flow.async_progress()[0]["context"]["source"] == "reauth"
async def test_unknown_auth_http_401(hass):
async def test_unknown_auth_http_401(hass: HomeAssistant) -> None:
"""Config entry state is SETUP_ERROR when august gets an http."""
config_entry = MockConfigEntry(
@ -310,7 +312,7 @@ async def test_unknown_auth_http_401(hass):
assert flows[0]["step_id"] == "reauth_validate"
async def test_load_unload(hass):
async def test_load_unload(hass: HomeAssistant) -> None:
"""Config entry can be unloaded."""
august_operative_lock = await _mock_operative_august_lock_detail(hass)
@ -325,7 +327,7 @@ async def test_load_unload(hass):
await hass.async_block_till_done()
async def test_load_triggers_ble_discovery(hass):
async def test_load_triggers_ble_discovery(hass: HomeAssistant) -> None:
"""Test that loading a lock that supports offline ble operation passes the keys to yalexe_ble."""
august_lock_with_key = await _mock_lock_with_offline_key(hass)
@ -364,7 +366,9 @@ async def remove_device(ws_client, device_id, config_entry_id):
return response["success"]
async def test_device_remove_devices(hass, hass_ws_client):
async def test_device_remove_devices(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
) -> None:
"""Test we can only remove a device that no longer exists."""
assert await async_setup_component(hass, "config", {})
august_operative_lock = await _mock_operative_august_lock_detail(hass)