Ejemplo n.º 1
0
def given_no_alarms(context):
    followups = [
        'ask.cancel.alarm.plural', 'ask.cancel.desc.alarm',
        'ask.cancel.desc.alarm.recurring'
    ]
    no_alarms = ['alarms.list.empty']
    cancelled = [
        'alarm.cancelled.desc', 'alarm.cancelled.desc.recurring',
        'alarm.cancelled.multi', 'alarm.cancelled.recurring'
    ]

    print('ASKING QUESTION')
    emit_utterance(context.bus, 'cancel all alarms')
    for i in range(10):
        for message in context.bus.get_messages('speak'):
            if message.data.get('meta', {}).get('dialog') in followups:
                print('Answering yes!')
                time.sleep(1)
                wait_while_speaking()
                emit_utterance(context.bus, 'yes')
                wait_for_dialog(context.bus, cancelled)
                context.bus.clear_messages()
                return
            elif message.data.get('meta', {}).get('dialog') in no_alarms:
                context.bus.clear_messages()
                return
        time.sleep(1)
    context.bus.clear_messages()
Ejemplo n.º 2
0
def given_no_timers(context):
    followups = [
        'ask.cancel.running.plural', 'ask.cancel.desc.alarm.recurring'
    ]
    no_timers = [
        'no.active.timer', 'cancel.all', 'cancelled.single.timer',
        'cancelled.timer.named', 'cancelled.timer.named.with.ordinal',
        'cancelled.timer.with.ordinal'
    ]
    cancelled = [
        'cancel.all', 'cancelled.single.timer', 'cancelled.timer.named',
        'cancelled.timer.named.with.ordinal', 'cancelled.timer.with.ordinal'
    ]

    emit_utterance(context.bus, 'cancel all timers')
    for i in range(10):
        for message in context.bus.get_messages('speak'):
            if message.data.get('meta', {}).get('dialog') in followups:
                print('Answering yes!')
                time.sleep(3)
                wait_while_speaking()
                emit_utterance(context.bus, 'yes')
                wait_for_dialog(context.bus, cancelled)
                context.bus.clear_messages()
                return
            elif message.data.get('meta', {}).get('dialog') in no_timers:
                context.bus.clear_messages()
                return
        time.sleep(1)
Ejemplo n.º 3
0
def given_news_playing(context):
    emit_utterance(context.bus, "sing a song")
    wait_for_dialog(context.bus, ['singing'])
    wait_while_speaking()
    time.sleep(3)
    context.bus.clear_messages()
Ejemplo n.º 4
0
def given_set_alarm(context, alarm_time):
    emit_utterance(context.bus, 'set an alarm for {}'.format(alarm_time))
    wait_for_dialog(context.bus, ['alarm.scheduled.for.time'])
    context.bus.clear_messages()
Ejemplo n.º 5
0
def given_expired_timer(context):
    emit_utterance(context.bus, 'set a 3 second timer')
    wait_for_dialog(context.bus, ['started.timer'])
    time.sleep(4)
Ejemplo n.º 6
0
def given_set_timer(context):
    emit_utterance(context.bus, 'set a timer for 100 minutes')
    wait_for_dialog(context.bus, ['started.timer'])
    context.bus.clear_messages()
Ejemplo n.º 7
0
def given_set_named_timer(context, name):
    emit_utterance(context.bus,
                   'set a timer for 95 minutes called {}'.format(name))
    wait_for_dialog(context.bus, ['started.timer'])
    context.bus.clear_messages()
Ejemplo n.º 8
0
def given_set_timer_named(context, name, time):
    emit_utterance(context.bus,
                   'set a timer for {} time called {}'.format(time, name))
    wait_for_dialog(context.bus, ['started.timer.with.name'])
    context.bus.clear_messages()
Ejemplo n.º 9
0
def given_set_timer_lenght(context, timer_length):
    emit_utterance(context.bus, 'set a timer for {}'.format(timer_length))
    wait_for_dialog(context.bus, ['started.timer'])
    context.bus.clear_messages()