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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 610 additions and 307 deletions

View file

@ -27,7 +27,8 @@ from homeassistant.exceptions import Unauthorized
from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component
from tests.common import mock_restore_cache
from tests.common import MockUser, mock_restore_cache
from tests.typing import WebSocketGenerator
TEST_VAL_MIN = 2
TEST_VAL_MAX = 22
@ -219,7 +220,9 @@ async def test_no_initial_state_and_no_restore_state(hass: HomeAssistant) -> Non
assert str(state.state) == "unknown"
async def test_input_text_context(hass, hass_admin_user):
async def test_input_text_context(
hass: HomeAssistant, hass_admin_user: MockUser
) -> None:
"""Test that input_text context works."""
assert await async_setup_component(
hass, "input_text", {"input_text": {"t1": {"initial": "bla"}}}
@ -256,7 +259,9 @@ async def test_config_none(hass: HomeAssistant) -> None:
assert state.attributes[ATTR_MIN] == CONF_MIN_VALUE
async def test_reload(hass, hass_admin_user, hass_read_only_user):
async def test_reload(
hass: HomeAssistant, hass_admin_user: MockUser, hass_read_only_user: MockUser
) -> None:
"""Test reload service."""
count_start = len(hass.states.async_entity_ids())
@ -318,7 +323,7 @@ async def test_reload(hass, hass_admin_user, hass_read_only_user):
assert state_3.attributes[ATTR_MAX] == 21
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")
@ -328,7 +333,7 @@ async def test_load_from_storage(hass, storage_setup):
assert state.attributes[ATTR_MIN] == TEST_VAL_MIN
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={
@ -357,7 +362,9 @@ async def test_editable_state_attribute(hass, storage_setup):
assert state.attributes[ATTR_MIN] == 3
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={
@ -389,7 +396,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()
@ -414,7 +423,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_update(hass, hass_ws_client, storage_setup):
async def test_update(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, storage_setup
) -> None:
"""Test updating min/max updates the state."""
assert await storage_setup()
@ -458,7 +469,9 @@ async def test_update(hass, hass_ws_client, storage_setup):
assert state.attributes[ATTR_MAX] == TEST_VAL_MAX
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=[])
@ -492,7 +505,7 @@ async def test_ws_create(hass, hass_ws_client, storage_setup):
assert state.attributes[ATTR_MIN] == 0
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, {})