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:
@@ -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,
|
||||
|
||||
+717
-1572
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user