1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Add type hints to integration tests (part 11) (#87996)

This commit is contained in:
epenet
2023-02-13 14:22:49 +01:00
committed by GitHub
parent 8f2a764a43
commit 1e352b60df
48 changed files with 610 additions and 307 deletions

View File

@@ -22,7 +22,8 @@ from homeassistant.core import Context, CoreState, HomeAssistant, State
from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component
from tests.common import mock_component, mock_restore_cache
from tests.common import MockUser, mock_component, mock_restore_cache
from tests.typing import WebSocketGenerator
_LOGGER = logging.getLogger(__name__)
@@ -169,7 +170,9 @@ async def test_initial_state_overrules_restore_state(hass: HomeAssistant) -> Non
assert state.state == "on"
async def test_input_boolean_context(hass, hass_admin_user):
async def test_input_boolean_context(
hass: HomeAssistant, hass_admin_user: MockUser
) -> None:
"""Test that input_boolean context works."""
assert await async_setup_component(
hass, "input_boolean", {"input_boolean": {"ac": {CONF_INITIAL: True}}}
@@ -192,7 +195,7 @@ async def test_input_boolean_context(hass, hass_admin_user):
assert state2.context.user_id == hass_admin_user.id
async def test_reload(hass, hass_admin_user):
async def test_reload(hass: HomeAssistant, hass_admin_user: MockUser) -> None:
"""Test reload service."""
count_start = len(hass.states.async_entity_ids())
ent_reg = er.async_get(hass)
@@ -267,7 +270,7 @@ async def test_reload(hass, hass_admin_user):
assert state_2.attributes.get(ATTR_ICON) == "mdi:work_reloaded"
async def test_load_from_storage(hass, storage_setup):
async def test_load_from_storage(hass: HomeAssistant, storage_setup) -> None:
"""Test set up from storage."""
assert await storage_setup()
state = hass.states.get(f"{DOMAIN}.from_storage")
@@ -276,7 +279,7 @@ async def test_load_from_storage(hass, storage_setup):
assert state.attributes.get(ATTR_EDITABLE)
async def test_editable_state_attribute(hass, storage_setup):
async def test_editable_state_attribute(hass: HomeAssistant, storage_setup) -> None:
"""Test editable attribute."""
assert await storage_setup(config={DOMAIN: {"from_yaml": None}})
@@ -290,7 +293,9 @@ async def test_editable_state_attribute(hass, storage_setup):
assert not state.attributes.get(ATTR_EDITABLE)
async def test_ws_list(hass, hass_ws_client, storage_setup):
async def test_ws_list(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, storage_setup
) -> None:
"""Test listing via WS."""
assert await storage_setup(config={DOMAIN: {"from_yaml": None}})
@@ -310,7 +315,9 @@ async def test_ws_list(hass, hass_ws_client, storage_setup):
assert result[storage_ent][ATTR_NAME] == "from storage"
async def test_ws_delete(hass, hass_ws_client, storage_setup):
async def test_ws_delete(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, storage_setup
) -> None:
"""Test WS delete cleans up entity registry."""
assert await storage_setup()
@@ -335,7 +342,9 @@ async def test_ws_delete(hass, hass_ws_client, storage_setup):
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, input_id) is None
async def test_ws_update(hass, hass_ws_client, storage_setup):
async def test_ws_update(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, storage_setup
) -> None:
"""Test update WS."""
settings = {
@@ -390,7 +399,9 @@ async def test_ws_update(hass, hass_ws_client, storage_setup):
assert state.attributes["friendly_name"] == "new_name_2"
async def test_ws_create(hass, hass_ws_client, storage_setup):
async def test_ws_create(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, storage_setup
) -> None:
"""Test create WS."""
assert await storage_setup(items=[])
@@ -418,7 +429,7 @@ async def test_ws_create(hass, hass_ws_client, storage_setup):
assert state.state
async def test_setup_no_config(hass, hass_admin_user):
async def test_setup_no_config(hass: HomeAssistant, hass_admin_user: MockUser) -> None:
"""Test component setup with no config."""
count_start = len(hass.states.async_entity_ids())
assert await async_setup_component(hass, DOMAIN, {})

View File

@@ -4,6 +4,7 @@ from __future__ import annotations
from datetime import timedelta
from homeassistant.components.input_boolean import DOMAIN
from homeassistant.components.recorder import Recorder
from homeassistant.components.recorder.db_schema import StateAttributes, States
from homeassistant.components.recorder.util import session_scope
from homeassistant.const import ATTR_EDITABLE
@@ -16,8 +17,8 @@ from tests.components.recorder.common import async_wait_recording_done
async def test_exclude_attributes(
recorder_mock, hass: HomeAssistant, enable_custom_integrations: None
):
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
) -> None:
"""Test attributes to be excluded."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})