mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add track_template_result method to events (#38802)
* Merge original changes from #23590 * guard * adjust * adjust * adjust * Update async_render_to_info for recent codebase changes * no more protected access * do not fire right away per review comments * update test to not fire right away * closer * rework tests for non firing first * augment coverage * remove cruft * test for complex listen add/remove * update docs to match review feedback to not fire right away * preserve existing behavior * fix test * Ensure listeners are cleaned up * de-dupe and comment * de-dupe and comment * coverage * test to login again if we go from exception to ok to exception * Update homeassistant/core.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/helpers/event.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * rename _boolean_coerce to result_as_boolean and move it out of event * additional coverage * Add more tests (may still be able to trim this down) Co-authored-by: Swamp-Ig <github@ninjateaparty.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""Test the condition helper."""
|
||||
from logging import ERROR
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
@@ -576,3 +578,18 @@ async def test_extract_devices():
|
||||
],
|
||||
}
|
||||
) == {"abcd", "qwer", "abcd_not", "qwer_not", "abcd_or", "qwer_or"}
|
||||
|
||||
|
||||
async def test_condition_template_error(hass, caplog):
|
||||
"""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:"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user