From 876f270c576b435a270ad0128c637dbc4cf11c39 Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Thu, 18 May 2017 15:55:52 -0400 Subject: [PATCH] forgot to commit the test --- tests/components/light/test_template.py | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/components/light/test_template.py b/tests/components/light/test_template.py index 8be8d186c03..a7dd428365c 100644 --- a/tests/components/light/test_template.py +++ b/tests/components/light/test_template.py @@ -470,6 +470,45 @@ class TestTemplateLight: # need to add assertions about optimistic state # assert state.attributes.get('brightness') == 124 + def test_level_template(self): + """Test the setting of the state with off.""" + with assert_setup_component(1): + assert setup.setup_component(self.hass, 'light', { + 'light': { + 'platform': 'template', + 'lights': { + 'test_template_light': { + 'value_template': "{{ 1 == 2 }}", + 'turn_on': { + 'service': 'light.turn_on', + 'entity_id': 'light.test_state' + }, + 'turn_off': { + 'service': 'light.turn_off', + 'entity_id': 'light.test_state' + }, + 'set_level': { + 'service': 'light.turn_on', + 'data_template': { + 'entity_id': 'light.test_state', + 'brightness': '{{brightness}}' + } + }, + 'level_template': + '{{42}}' + } + } + } + }) + + self.hass.start() + self.hass.block_till_done() + + state = self.hass.states.get('light.test_template_light') + assert state != None + _LOGGER.error(str(state)) + assert state.attributes.get('brightness') == 42 + @asyncio.coroutine def test_restore_state(hass): """Ensure states are restored on startup."""