1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Update template sensor to use async_track_template_result (#38940)

* Add template entity

* Update template tracking to work for template sensors

* add test for whitespace

* Update homeassistant/helpers/config_validation.py

* revert

* fix

* reduce

* fix _refresh missing decorator

* defer until start

* do not throw errors during startup

* defer tracking until start event

Co-authored-by: Swamp-Ig <github@ninjateaparty.com>
This commit is contained in:
J. Nick Koston
2020-08-20 08:06:41 -05:00
committed by GitHub
parent b7ec0d4884
commit 1381b279f0
8 changed files with 295 additions and 151 deletions

View File

@@ -1092,3 +1092,24 @@ def test_script(caplog):
cv.script_action(data)
assert msg in str(excinfo.value)
def test_whitespace():
"""Test whitespace validation."""
schema = vol.Schema(cv.whitespace)
for value in (
None,
"" "T",
"negative",
"lock",
"tr ue",
[],
[1, 2],
{"one": "two"},
):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in (" ", " "):
assert schema(value)