'Test if we can use conditions in a script.'

def test_condition(self):

    event = 'test_event'
    events = []
    @callback
    def record_event(event):
        'Add    recorded    event    to    set.'
        events.append(event)
    self.hass.bus.listen(event, record_event)
    self.hass.states.set('test.entity', 'hello')
    script_obj = script.Script(self.hass, cv.SCRIPT_SCHEMA([{'event': event}, {'condition': 'template', 'value_template': '{{    states.test.entity.state    ==    "hello"    }}'}, {'event': event}]))
    script_obj.run()
    self.hass.block_till_done()
    assert (len(events) == 2)
    self.hass.states.set('test.entity', 'goodbye')
    script_obj.run()
    self.hass.block_till_done()
    assert (len(events) == 3)
