<s> """<STR_LIT>""" <EOL> import homeassistant . components . sensor as sensor <EOL> from tests . common import get_test_home_assistant <EOL> class TestTemplateSensor : <EOL> """<STR_LIT>""" <EOL> def setup_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> self . hass = get_test_home_assistant ( ) <EOL> def teardown_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> self . hass . stop ( ) <EOL> def test_template ( self ) : <EOL> """<STR_LIT>""" <EOL> assert sensor . setup ( self . hass , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> } ) <EOL> state = self . hass . states . get ( '<STR_LIT>' ) <EOL> assert state . state == '<STR_LIT>' <EOL> self . hass . states . set ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . hass . pool . block_till_done ( ) <EOL> state = self . hass . states . get ( '<STR_LIT>' ) <EOL> assert state . state == '<STR_LIT>' <EOL> def test_template_syntax_error ( self ) : <EOL> """<STR_LIT>""" <EOL> assert sensor . setup ( self . hass , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> } ) <EOL> self . hass . states . set ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . hass . pool . block_till_done ( ) <EOL> state = self . hass . states . get ( '<STR_LIT>' ) <EOL> assert state . state == '<STR_LIT>' <EOL> def test_template_attribute_missing ( self ) : <EOL> """<STR_LIT>""" <EOL> assert sensor . setup ( self . hass , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> } ) <EOL> state = self . hass . states . get ( '<STR_LIT>' ) <EOL> assert state . state == '<STR_LIT>' <EOL> def test_invalid_name_does_not_create ( self ) : <EOL> """<STR_LIT>""" <EOL> assert sensor . setup ( self . hass , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> } ) <EOL> assert self . hass . states . all ( ) == [ ] <EOL> def test_invalid_sensor_does_not_create ( self ) : <EOL> """<STR_LIT>""" <EOL> assert sensor . setup ( self . hass , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } <EOL> } ) <EOL> assert self . hass . states . all ( ) == [ ] <EOL> def test_no_sensors_does_not_create ( self ) : <EOL> """<STR_LIT>""" <EOL> assert sensor . setup ( self . hass , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } ) <EOL> assert self . hass . states . all ( ) == [ ] <EOL> def test_missing_template_does_not_create ( self ) : <EOL> """<STR_LIT>""" <EOL> assert sensor . setup ( self . hass , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> } ) <EOL> assert self . hass . states . all ( ) == [ ] </s>
