Add type hints to integration tests (part 2) (#88493)

This commit is contained in:
epenet
2023-02-21 09:25:05 +01:00
committed by GitHub
parent ebb450c946
commit a102883eff
42 changed files with 367 additions and 230 deletions

View File

@@ -3,7 +3,7 @@ import pytest
import homeassistant.components.automation as automation
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL, SERVICE_TURN_OFF
from homeassistant.core import Context
from homeassistant.core import Context, HomeAssistant
from homeassistant.setup import async_setup_component
from tests.common import async_mock_service, mock_component
@@ -27,7 +27,7 @@ def setup_comp(hass):
mock_component(hass, "group")
async def test_if_fires_on_event(hass, calls):
async def test_if_fires_on_event(hass: HomeAssistant, calls) -> None:
"""Test the firing of events."""
context = Context()
@@ -63,7 +63,7 @@ async def test_if_fires_on_event(hass, calls):
assert calls[0].data["id"] == 0
async def test_if_fires_on_templated_event(hass, calls):
async def test_if_fires_on_templated_event(hass: HomeAssistant, calls) -> None:
"""Test the firing of events."""
context = Context()
@@ -96,7 +96,7 @@ async def test_if_fires_on_templated_event(hass, calls):
assert len(calls) == 1
async def test_if_fires_on_multiple_events(hass, calls):
async def test_if_fires_on_multiple_events(hass: HomeAssistant, calls) -> None:
"""Test the firing of events."""
context = Context()
@@ -123,7 +123,9 @@ async def test_if_fires_on_multiple_events(hass, calls):
assert calls[1].context.parent_id == context.id
async def test_if_fires_on_event_extra_data(hass, calls, context_with_user):
async def test_if_fires_on_event_extra_data(
hass: HomeAssistant, calls, context_with_user
) -> None:
"""Test the firing of events still matches with event data and context."""
assert await async_setup_component(
hass,
@@ -153,7 +155,9 @@ async def test_if_fires_on_event_extra_data(hass, calls, context_with_user):
assert len(calls) == 1
async def test_if_fires_on_event_with_data_and_context(hass, calls, context_with_user):
async def test_if_fires_on_event_with_data_and_context(
hass: HomeAssistant, calls, context_with_user
) -> None:
"""Test the firing of events with data and context."""
assert await async_setup_component(
hass,
@@ -199,8 +203,8 @@ async def test_if_fires_on_event_with_data_and_context(hass, calls, context_with
async def test_if_fires_on_event_with_templated_data_and_context(
hass, calls, context_with_user
):
hass: HomeAssistant, calls, context_with_user
) -> None:
"""Test the firing of events with templated data and context."""
assert await async_setup_component(
hass,
@@ -251,8 +255,8 @@ async def test_if_fires_on_event_with_templated_data_and_context(
async def test_if_fires_on_event_with_empty_data_and_context_config(
hass, calls, context_with_user
):
hass: HomeAssistant, calls, context_with_user
) -> None:
"""Test the firing of events with empty data and context config.
The frontend automation editor can produce configurations with an
@@ -283,7 +287,7 @@ async def test_if_fires_on_event_with_empty_data_and_context_config(
assert len(calls) == 1
async def test_if_fires_on_event_with_nested_data(hass, calls):
async def test_if_fires_on_event_with_nested_data(hass: HomeAssistant, calls) -> None:
"""Test the firing of events with nested data."""
assert await async_setup_component(
hass,
@@ -307,7 +311,9 @@ async def test_if_fires_on_event_with_nested_data(hass, calls):
assert len(calls) == 1
async def test_if_not_fires_if_event_data_not_matches(hass, calls):
async def test_if_not_fires_if_event_data_not_matches(
hass: HomeAssistant, calls
) -> None:
"""Test firing of event if no data match."""
assert await async_setup_component(
hass,
@@ -330,8 +336,8 @@ async def test_if_not_fires_if_event_data_not_matches(hass, calls):
async def test_if_not_fires_if_event_context_not_matches(
hass, calls, context_with_user
):
hass: HomeAssistant, calls, context_with_user
) -> None:
"""Test firing of event if no context match."""
assert await async_setup_component(
hass,
@@ -353,7 +359,9 @@ async def test_if_not_fires_if_event_context_not_matches(
assert len(calls) == 0
async def test_if_fires_on_multiple_user_ids(hass, calls, context_with_user):
async def test_if_fires_on_multiple_user_ids(
hass: HomeAssistant, calls, context_with_user
) -> None:
"""Test the firing of event when the trigger has multiple user ids."""
assert await async_setup_component(
hass,
@@ -376,7 +384,7 @@ async def test_if_fires_on_multiple_user_ids(hass, calls, context_with_user):
assert len(calls) == 1
async def test_event_data_with_list(hass, calls):
async def test_event_data_with_list(hass: HomeAssistant, calls) -> None:
"""Test the (non)firing of event when the data schema has lists."""
assert await async_setup_component(
hass,