mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 02:38:10 +02:00
Add type hints to integration tests (part 11) (#87996)
This commit is contained in:
@ -31,7 +31,8 @@ from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import mock_restore_cache
|
||||
from tests.common import MockUser, mock_restore_cache
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
INITIAL_DATE = "2020-01-10"
|
||||
INITIAL_TIME = "23:45:56"
|
||||
@ -114,7 +115,7 @@ async def async_set_timestamp(hass, entity_id, timestamp):
|
||||
{"test_no_value": {"has_time": False, "has_date": False}},
|
||||
],
|
||||
)
|
||||
def test_invalid_configs(config):
|
||||
def test_invalid_configs(config) -> None:
|
||||
"""Test config."""
|
||||
with pytest.raises(vol.Invalid):
|
||||
CONFIG_SCHEMA({DOMAIN: config})
|
||||
@ -392,7 +393,9 @@ async def test_default_value(hass: HomeAssistant) -> None:
|
||||
assert state_datetime.attributes.get("timestamp") is not None
|
||||
|
||||
|
||||
async def test_input_datetime_context(hass, hass_admin_user):
|
||||
async def test_input_datetime_context(
|
||||
hass: HomeAssistant, hass_admin_user: MockUser
|
||||
) -> None:
|
||||
"""Test that input_datetime context works."""
|
||||
assert await async_setup_component(
|
||||
hass, "input_datetime", {"input_datetime": {"only_date": {"has_date": True}}}
|
||||
@ -415,7 +418,9 @@ async def test_input_datetime_context(hass, hass_admin_user):
|
||||
assert state2.context.user_id == hass_admin_user.id
|
||||
|
||||
|
||||
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())
|
||||
ent_reg = er.async_get(hass)
|
||||
@ -489,7 +494,7 @@ async def test_reload(hass, hass_admin_user, hass_read_only_user):
|
||||
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "dt3") is None
|
||||
|
||||
|
||||
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}.datetime_from_storage")
|
||||
@ -497,7 +502,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={
|
||||
@ -521,7 +526,9 @@ async def test_editable_state_attribute(hass, storage_setup):
|
||||
assert not state.attributes[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": {CONF_HAS_DATE: True}}})
|
||||
|
||||
@ -541,7 +548,9 @@ async def test_ws_list(hass, hass_ws_client, storage_setup):
|
||||
assert result[storage_ent][ATTR_NAME] == "datetime 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()
|
||||
|
||||
@ -566,7 +575,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()
|
||||
@ -605,7 +616,9 @@ async def test_update(hass, hass_ws_client, storage_setup):
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "even newer name"
|
||||
|
||||
|
||||
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=[])
|
||||
|
||||
@ -638,7 +651,7 @@ async def test_ws_create(hass, hass_ws_client, storage_setup):
|
||||
assert state.attributes[ATTR_EDITABLE]
|
||||
|
||||
|
||||
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, {})
|
||||
@ -768,7 +781,9 @@ async def test_timestamp(hass: HomeAssistant) -> None:
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_invalid_initial(hass, caplog, config, error):
|
||||
async def test_invalid_initial(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, config, error
|
||||
) -> None:
|
||||
"""Test configuration is rejected if the initial value is invalid."""
|
||||
assert not await async_setup_component(
|
||||
hass,
|
||||
|
Reference in New Issue
Block a user