Allow jinja namespace command to work. (#18011)
This commit is contained in:
1 parent
4d9ef9e795
commit
865ea82432
2 files changed
+23
No files matched your search
@@ -963,6 +963,23 @@ class TestHelpersTemplate(unittest.TestCase):
|
||||
"{{ is_state('media_player.' ~ where , 'playing') }}",
|
||||
{'where': 'livingroom'})
|
||||
|
||||
def test_jinja_namespace(self):
|
||||
"""Test Jinja's namespace command can be used."""
|
||||
test_template = template.Template(
|
||||
(
|
||||
"{% set ns = namespace(a_key='') %}"
|
||||
"{% set ns.a_key = states.sensor.dummy.state %}"
|
||||
"{{ ns.a_key }}"
|
||||
),
|
||||
self.hass
|
||||
)
|
||||
|
||||
self.hass.states.set('sensor.dummy', 'a value')
|
||||
assert 'a value' == test_template.render()
|
||||
|
||||
self.hass.states.set('sensor.dummy', 'another value')
|
||||
assert 'another value' == test_template.render()
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_state_with_unit(hass):
|
||||
|
||||
Reference in new issue
Block a user