1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-07 14:56:25 +01:00

Update template light test framework (#164688)

This commit is contained in:
Petro31
2026-03-06 14:12:10 -05:00
committed by GitHub
parent 1471cb93bc
commit b8ea6b4162
2 changed files with 743 additions and 1572 deletions
+26
View File
@@ -51,6 +51,32 @@ def make_test_trigger(*entities: str) -> dict:
}
def make_test_action(action: str, extra_data: ConfigType | None = None) -> ConfigType:
"""Make a test action."""
data = extra_data or {}
return {
action: {
"action": "test.automation",
"data": {"caller": "{{ this.entity_id }}", "action": action, **data},
}
}
def assert_action(
platform_setup: TemplatePlatformSetup,
calls: list[ServiceCall],
expected_calls: int,
expected_action: str,
**kwargs,
) -> None:
"""Validate the action was properly called."""
assert len(calls) == expected_calls
assert calls[-1].data["action"] == expected_action
assert calls[-1].data["caller"] == platform_setup.entity_id
for key, value in kwargs.items():
assert calls[-1].data[key] == value
async def async_trigger(
hass: HomeAssistant,
entity_id: str,
File diff suppressed because it is too large Load Diff