Tidy, add test for ValueException logic.
This commit is contained in:
parent
8b5751ad44
commit
b1f7b5c6d7
1 changed files with 23 additions and 4 deletions
|
@ -12,8 +12,8 @@ import homeassistant.core as ha
|
|||
import homeassistant.components.sensor as sensor
|
||||
|
||||
|
||||
class TestSensorYr:
|
||||
""" Test the Yr sensor. """
|
||||
class TestTemplateSensor:
|
||||
""" Test the Template sensor. """
|
||||
|
||||
def setup_method(self, method):
|
||||
self.hass = ha.HomeAssistant()
|
||||
|
@ -22,14 +22,14 @@ class TestSensorYr:
|
|||
""" Stop down stuff we started. """
|
||||
self.hass.stop()
|
||||
|
||||
def test_template(self, betamax_session):
|
||||
def test_template(self):
|
||||
assert sensor.setup(self.hass, {
|
||||
'sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
'test_template_sensor': {
|
||||
'value_template':
|
||||
'{{ states.sensor.test_state.state }}'
|
||||
"{{ states.sensor.test_state.state }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,3 +42,22 @@ class TestSensorYr:
|
|||
self.hass.pool.block_till_done()
|
||||
state = self.hass.states.get('sensor.test_template_sensor')
|
||||
assert state.state == 'Works'
|
||||
|
||||
def test_template_syntax_error(self):
|
||||
assert sensor.setup(self.hass, {
|
||||
'sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
'test_template_sensor': {
|
||||
'value_template':
|
||||
"{% if rubbish %}"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set('sensor.test_state', 'Works')
|
||||
self.hass.pool.block_till_done()
|
||||
state = self.hass.states.get('sensor.test_template_sensor')
|
||||
assert state.state == 'unknown'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue