Allow conditions to be implemented in platforms (#88509)

* Allow conditions to be implemented in platforms

* Update tests

* Tweak typing

* Rebase fixes
This commit is contained in:
Erik Montnemery
2023-02-24 04:30:51 +01:00
committed by GitHub
parent 2f826a6f86
commit d90ee85118
3 changed files with 77 additions and 52 deletions

View File

@@ -2406,13 +2406,7 @@ async def test_repeat_var_in_condition(hass: HomeAssistant, condition) -> None:
script_obj = script.Script(
hass, cv.SCRIPT_SCHEMA(sequence), "Test Name", "test_domain"
)
with mock.patch(
"homeassistant.helpers.condition._LOGGER.error",
side_effect=AssertionError("Template Error"),
):
await script_obj.async_run(context=Context())
await script_obj.async_run(context=Context())
assert len(events) == 2
if condition == "while":
@@ -2545,13 +2539,7 @@ async def test_repeat_nested(
]
)
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
with mock.patch(
"homeassistant.helpers.condition._LOGGER.error",
side_effect=AssertionError("Template Error"),
):
await script_obj.async_run(variables, Context())
await script_obj.async_run(variables, Context())
assert len(events) == 10
assert events[0].data == first_last
assert events[-1].data == first_last