'Test the wait template.'

def test_wait_template_timeout(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('switch.test', 'on')
    script_obj = script.Script(self.hass, cv.SCRIPT_SCHEMA([{'event': event}, {'wait_template': "{{states.switch.test.state    ==    'off'}}", 'timeout': 5}, {'event': event}]))
    script_obj.run()
    self.hass.block_till_done()
    assert script_obj.is_running
    assert script_obj.can_cancel
    assert (script_obj.last_action == event)
    assert (len(events) == 1)
    future = (dt_util.utcnow() + timedelta(seconds=5))
    fire_time_changed(self.hass, future)
    self.hass.block_till_done()
    assert (not script_obj.is_running)
    assert (len(events) == 1)
