Raise ConditionError for template errors (#46245)
This commit is contained in:
parent
e013ad2413
commit
1f5fb8f28a
2 changed files with 5 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
"""Test the condition helper."""
|
||||
from logging import ERROR, WARNING
|
||||
from logging import WARNING
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
@ -1041,19 +1041,14 @@ async def test_extract_devices():
|
|||
)
|
||||
|
||||
|
||||
async def test_condition_template_error(hass, caplog):
|
||||
async def test_condition_template_error(hass):
|
||||
"""Test invalid template."""
|
||||
caplog.set_level(ERROR)
|
||||
|
||||
test = await condition.async_from_config(
|
||||
hass, {"condition": "template", "value_template": "{{ undefined.state }}"}
|
||||
)
|
||||
|
||||
assert not test(hass)
|
||||
assert len(caplog.records) == 1
|
||||
assert caplog.records[0].message.startswith(
|
||||
"Error during template condition: UndefinedError:"
|
||||
)
|
||||
with pytest.raises(ConditionError, match="template"):
|
||||
test(hass)
|
||||
|
||||
|
||||
async def test_condition_template_invalid_results(hass):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue