Improve typing for calls
fixture in tests (a-l) (#118349)
* Improve typing for `calls` fixture in tests (a-l) * More * More
This commit is contained in:
parent
89ae425ac2
commit
7e62061b9a
43 changed files with 546 additions and 338 deletions
|
@ -40,7 +40,9 @@ def setup_comp(hass):
|
|||
hass.states.async_set("test.entity", "hello")
|
||||
|
||||
|
||||
async def test_if_fires_on_entity_change(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fires_on_entity_change(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change."""
|
||||
context = Context()
|
||||
hass.states.async_set("test.entity", "hello")
|
||||
|
@ -88,7 +90,7 @@ async def test_if_fires_on_entity_change(hass: HomeAssistant, calls) -> None:
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_uuid(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change."""
|
||||
context = Context()
|
||||
|
@ -144,7 +146,7 @@ async def test_if_fires_on_entity_change_uuid(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_from_filter(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with filter."""
|
||||
assert await async_setup_component(
|
||||
|
@ -199,7 +201,7 @@ async def test_if_fires_on_entity_change_with_not_from_filter(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_to_filter(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with to filter."""
|
||||
assert await async_setup_component(
|
||||
|
@ -254,7 +256,7 @@ async def test_if_fires_on_entity_change_with_not_to_filter(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_from_filter_all(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with filter."""
|
||||
assert await async_setup_component(
|
||||
|
@ -280,7 +282,7 @@ async def test_if_fires_on_entity_change_with_from_filter_all(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_to_filter_all(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with to filter."""
|
||||
assert await async_setup_component(
|
||||
|
@ -306,7 +308,7 @@ async def test_if_fires_on_entity_change_with_to_filter_all(
|
|||
|
||||
|
||||
async def test_if_fires_on_attribute_change_with_to_filter(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for not firing on attribute change."""
|
||||
assert await async_setup_component(
|
||||
|
@ -332,7 +334,7 @@ async def test_if_fires_on_attribute_change_with_to_filter(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_both_filters(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if both filters are a non match."""
|
||||
assert await async_setup_component(
|
||||
|
@ -451,7 +453,9 @@ async def test_if_fires_on_entity_change_with_from_not_to(
|
|||
assert len(calls) == 2
|
||||
|
||||
|
||||
async def test_if_not_fires_if_to_filter_not_match(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_not_fires_if_to_filter_not_match(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for not firing if to filter is not a match."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -476,7 +480,7 @@ async def test_if_not_fires_if_to_filter_not_match(hass: HomeAssistant, calls) -
|
|||
|
||||
|
||||
async def test_if_not_fires_if_from_filter_not_match(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for not firing if from filter is not a match."""
|
||||
hass.states.async_set("test.entity", "bye")
|
||||
|
@ -503,7 +507,9 @@ async def test_if_not_fires_if_from_filter_not_match(
|
|||
assert len(calls) == 0
|
||||
|
||||
|
||||
async def test_if_not_fires_if_entity_not_match(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_not_fires_if_entity_not_match(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for not firing if entity is not matching."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -522,7 +528,7 @@ async def test_if_not_fires_if_entity_not_match(hass: HomeAssistant, calls) -> N
|
|||
assert len(calls) == 0
|
||||
|
||||
|
||||
async def test_if_action(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_action(hass: HomeAssistant, calls: list[ServiceCall]) -> None:
|
||||
"""Test for to action."""
|
||||
entity_id = "domain.test_entity"
|
||||
test_state = "new_state"
|
||||
|
@ -554,7 +560,9 @@ async def test_if_action(hass: HomeAssistant, calls) -> None:
|
|||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_if_fails_setup_if_to_boolean_value(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fails_setup_if_to_boolean_value(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for setup failure for boolean to."""
|
||||
with assert_setup_component(1, automation.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
|
@ -574,7 +582,9 @@ async def test_if_fails_setup_if_to_boolean_value(hass: HomeAssistant, calls) ->
|
|||
assert hass.states.get("automation.automation_0").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_if_fails_setup_if_from_boolean_value(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fails_setup_if_from_boolean_value(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for setup failure for boolean from."""
|
||||
with assert_setup_component(1, automation.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
|
@ -594,7 +604,9 @@ async def test_if_fails_setup_if_from_boolean_value(hass: HomeAssistant, calls)
|
|||
assert hass.states.get("automation.automation_0").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_if_fails_setup_bad_for(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fails_setup_bad_for(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for setup failure for bad for."""
|
||||
with assert_setup_component(1, automation.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
|
@ -616,7 +628,7 @@ async def test_if_fails_setup_bad_for(hass: HomeAssistant, calls) -> None:
|
|||
|
||||
|
||||
async def test_if_not_fires_on_entity_change_with_for(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for not firing on entity change with for."""
|
||||
assert await async_setup_component(
|
||||
|
@ -646,7 +658,7 @@ async def test_if_not_fires_on_entity_change_with_for(
|
|||
|
||||
|
||||
async def test_if_not_fires_on_entities_change_with_for_after_stop(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for not firing on entity change with for after stop trigger."""
|
||||
assert await async_setup_component(
|
||||
|
@ -695,7 +707,7 @@ async def test_if_not_fires_on_entities_change_with_for_after_stop(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_for_attribute_change(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with for and attribute change."""
|
||||
assert await async_setup_component(
|
||||
|
@ -731,7 +743,7 @@ async def test_if_fires_on_entity_change_with_for_attribute_change(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_for_multiple_force_update(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with for and force update."""
|
||||
assert await async_setup_component(
|
||||
|
@ -765,7 +777,9 @@ async def test_if_fires_on_entity_change_with_for_multiple_force_update(
|
|||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_for(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fires_on_entity_change_with_for(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with for."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -792,7 +806,7 @@ async def test_if_fires_on_entity_change_with_for(hass: HomeAssistant, calls) ->
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_change_with_for_without_to(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with for."""
|
||||
assert await async_setup_component(
|
||||
|
@ -831,7 +845,7 @@ async def test_if_fires_on_entity_change_with_for_without_to(
|
|||
|
||||
|
||||
async def test_if_does_not_fires_on_entity_change_with_for_without_to_2(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity change with for."""
|
||||
assert await async_setup_component(
|
||||
|
@ -861,7 +875,7 @@ async def test_if_does_not_fires_on_entity_change_with_for_without_to_2(
|
|||
|
||||
|
||||
async def test_if_fires_on_entity_creation_and_removal(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entity creation and removal, with to/from constraints."""
|
||||
# set automations for multiple combinations to/from
|
||||
|
@ -927,7 +941,9 @@ async def test_if_fires_on_entity_creation_and_removal(
|
|||
assert calls[3].context.parent_id == context_0.id
|
||||
|
||||
|
||||
async def test_if_fires_on_for_condition(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fires_on_for_condition(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if condition is on."""
|
||||
point1 = dt_util.utcnow()
|
||||
point2 = point1 + timedelta(seconds=10)
|
||||
|
@ -965,7 +981,7 @@ async def test_if_fires_on_for_condition(hass: HomeAssistant, calls) -> None:
|
|||
|
||||
|
||||
async def test_if_fires_on_for_condition_attribute_change(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if condition is on with attribute change."""
|
||||
point1 = dt_util.utcnow()
|
||||
|
@ -1013,7 +1029,9 @@ async def test_if_fires_on_for_condition_attribute_change(
|
|||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_if_fails_setup_for_without_time(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fails_setup_for_without_time(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for setup failure if no time is provided."""
|
||||
with assert_setup_component(1, automation.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
|
@ -1035,7 +1053,9 @@ async def test_if_fails_setup_for_without_time(hass: HomeAssistant, calls) -> No
|
|||
assert hass.states.get("automation.automation_0").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_if_fails_setup_for_without_entity(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fails_setup_for_without_entity(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for setup failure if no entity is provided."""
|
||||
with assert_setup_component(1, automation.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
|
@ -1056,7 +1076,9 @@ async def test_if_fails_setup_for_without_entity(hass: HomeAssistant, calls) ->
|
|||
assert hass.states.get("automation.automation_0").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_wait_template_with_trigger(hass: HomeAssistant, calls) -> None:
|
||||
async def test_wait_template_with_trigger(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test using wait template with 'trigger.entity_id'."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -1096,7 +1118,7 @@ async def test_wait_template_with_trigger(hass: HomeAssistant, calls) -> None:
|
|||
|
||||
|
||||
async def test_if_fires_on_entities_change_no_overlap(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entities change with no overlap."""
|
||||
assert await async_setup_component(
|
||||
|
@ -1137,7 +1159,7 @@ async def test_if_fires_on_entities_change_no_overlap(
|
|||
|
||||
|
||||
async def test_if_fires_on_entities_change_overlap(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entities change with overlap."""
|
||||
assert await async_setup_component(
|
||||
|
@ -1189,7 +1211,7 @@ async def test_if_fires_on_entities_change_overlap(
|
|||
|
||||
|
||||
async def test_if_fires_on_change_with_for_template_1(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on change with for template."""
|
||||
assert await async_setup_component(
|
||||
|
@ -1217,7 +1239,7 @@ async def test_if_fires_on_change_with_for_template_1(
|
|||
|
||||
|
||||
async def test_if_fires_on_change_with_for_template_2(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on change with for template."""
|
||||
assert await async_setup_component(
|
||||
|
@ -1245,7 +1267,7 @@ async def test_if_fires_on_change_with_for_template_2(
|
|||
|
||||
|
||||
async def test_if_fires_on_change_with_for_template_3(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on change with for template."""
|
||||
assert await async_setup_component(
|
||||
|
@ -1273,7 +1295,7 @@ async def test_if_fires_on_change_with_for_template_3(
|
|||
|
||||
|
||||
async def test_if_fires_on_change_with_for_template_4(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on change with for template."""
|
||||
assert await async_setup_component(
|
||||
|
@ -1301,7 +1323,9 @@ async def test_if_fires_on_change_with_for_template_4(
|
|||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_if_fires_on_change_from_with_for(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_fires_on_change_from_with_for(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on change with from/for."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -1330,7 +1354,9 @@ async def test_if_fires_on_change_from_with_for(hass: HomeAssistant, calls) -> N
|
|||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_if_not_fires_on_change_from_with_for(hass: HomeAssistant, calls) -> None:
|
||||
async def test_if_not_fires_on_change_from_with_for(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on change with from/for."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -1359,7 +1385,9 @@ async def test_if_not_fires_on_change_from_with_for(hass: HomeAssistant, calls)
|
|||
assert len(calls) == 0
|
||||
|
||||
|
||||
async def test_invalid_for_template_1(hass: HomeAssistant, calls) -> None:
|
||||
async def test_invalid_for_template_1(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for invalid for template."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -1384,7 +1412,7 @@ async def test_invalid_for_template_1(hass: HomeAssistant, calls) -> None:
|
|||
|
||||
|
||||
async def test_if_fires_on_entities_change_overlap_for_template(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing on entities change with overlap and for template."""
|
||||
assert await async_setup_component(
|
||||
|
@ -1443,7 +1471,7 @@ async def test_if_fires_on_entities_change_overlap_for_template(
|
|||
|
||||
|
||||
async def test_attribute_if_fires_on_entity_change_with_both_filters(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if both filters are match attribute."""
|
||||
hass.states.async_set("test.entity", "bla", {"name": "hello"})
|
||||
|
@ -1472,7 +1500,7 @@ async def test_attribute_if_fires_on_entity_change_with_both_filters(
|
|||
|
||||
|
||||
async def test_attribute_if_fires_on_entity_where_attr_stays_constant(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if attribute stays the same."""
|
||||
hass.states.async_set("test.entity", "bla", {"name": "hello", "other": "old_value"})
|
||||
|
@ -1510,7 +1538,7 @@ async def test_attribute_if_fires_on_entity_where_attr_stays_constant(
|
|||
|
||||
|
||||
async def test_attribute_if_fires_on_entity_where_attr_stays_constant_filter(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if attribute stays the same."""
|
||||
hass.states.async_set("test.entity", "bla", {"name": "other_name"})
|
||||
|
@ -1555,7 +1583,7 @@ async def test_attribute_if_fires_on_entity_where_attr_stays_constant_filter(
|
|||
|
||||
|
||||
async def test_attribute_if_fires_on_entity_where_attr_stays_constant_all(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if attribute stays the same."""
|
||||
hass.states.async_set("test.entity", "bla", {"name": "hello", "other": "old_value"})
|
||||
|
@ -1600,7 +1628,7 @@ async def test_attribute_if_fires_on_entity_where_attr_stays_constant_all(
|
|||
|
||||
|
||||
async def test_attribute_if_not_fires_on_entities_change_with_for_after_stop(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for not firing on entity change with for after stop trigger."""
|
||||
hass.states.async_set("test.entity", "bla", {"name": "hello"})
|
||||
|
@ -1656,7 +1684,7 @@ async def test_attribute_if_not_fires_on_entities_change_with_for_after_stop(
|
|||
|
||||
|
||||
async def test_attribute_if_fires_on_entity_change_with_both_filters_boolean(
|
||||
hass: HomeAssistant, calls
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for firing if both filters are match attribute."""
|
||||
hass.states.async_set("test.entity", "bla", {"happening": False})
|
||||
|
@ -1685,7 +1713,7 @@ async def test_attribute_if_fires_on_entity_change_with_both_filters_boolean(
|
|||
|
||||
|
||||
async def test_variables_priority(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test an externally defined trigger variable is overridden."""
|
||||
assert await async_setup_component(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue