mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Tidy, add test for ValueException logic.
This commit is contained in:
parent
8b5751ad44
commit
b1f7b5c6d7
@ -12,8 +12,8 @@ import homeassistant.core as ha
|
|||||||
import homeassistant.components.sensor as sensor
|
import homeassistant.components.sensor as sensor
|
||||||
|
|
||||||
|
|
||||||
class TestSensorYr:
|
class TestTemplateSensor:
|
||||||
""" Test the Yr sensor. """
|
""" Test the Template sensor. """
|
||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
self.hass = ha.HomeAssistant()
|
self.hass = ha.HomeAssistant()
|
||||||
@ -22,14 +22,14 @@ class TestSensorYr:
|
|||||||
""" Stop down stuff we started. """
|
""" Stop down stuff we started. """
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
|
||||||
def test_template(self, betamax_session):
|
def test_template(self):
|
||||||
assert sensor.setup(self.hass, {
|
assert sensor.setup(self.hass, {
|
||||||
'sensor': {
|
'sensor': {
|
||||||
'platform': 'template',
|
'platform': 'template',
|
||||||
'sensors': {
|
'sensors': {
|
||||||
'test_template_sensor': {
|
'test_template_sensor': {
|
||||||
'value_template':
|
'value_template':
|
||||||
'{{ states.sensor.test_state.state }}'
|
"{{ states.sensor.test_state.state }}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,3 +42,22 @@ class TestSensorYr:
|
|||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
state = self.hass.states.get('sensor.test_template_sensor')
|
state = self.hass.states.get('sensor.test_template_sensor')
|
||||||
assert state.state == 'Works'
|
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…
x
Reference in New Issue
Block a user