mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Allow skip parsing template result (#42401)
This commit is contained in:
@@ -915,3 +915,26 @@ async def test_condition_template_error(hass, caplog):
|
||||
assert caplog.records[0].message.startswith(
|
||||
"Error during template condition: UndefinedError:"
|
||||
)
|
||||
|
||||
|
||||
async def test_condition_template_invalid_results(hass):
|
||||
"""Test template condition render false with invalid results."""
|
||||
test = await condition.async_from_config(
|
||||
hass, {"condition": "template", "value_template": "{{ 'string' }}"}
|
||||
)
|
||||
assert not test(hass)
|
||||
|
||||
test = await condition.async_from_config(
|
||||
hass, {"condition": "template", "value_template": "{{ 10.1 }}"}
|
||||
)
|
||||
assert not test(hass)
|
||||
|
||||
test = await condition.async_from_config(
|
||||
hass, {"condition": "template", "value_template": "{{ 42 }}"}
|
||||
)
|
||||
assert not test(hass)
|
||||
|
||||
test = await condition.async_from_config(
|
||||
hass, {"condition": "template", "value_template": "{{ [1, 2, 3] }}"}
|
||||
)
|
||||
assert not test(hass)
|
||||
|
||||
Reference in New Issue
Block a user