'Test the cancelling while the delay is present.'

def test_cancel_while_delay(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)
    script_obj = script.Script(self.hass, cv.SCRIPT_SCHEMA([{'delay': {'seconds': 5}}, {'event': event}]))
    script_obj.run()
    self.hass.block_till_done()
    assert script_obj.is_running
    assert (len(events) == 0)
    script_obj.stop()
    assert (not script_obj.is_running)
    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) == 0)
