Esempio 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()
Esempio 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)
def given_nothing_playing(context):
    emit_utterance(context.bus, "stop playback")
    time.sleep(5)
    context.bus.clear_messages()
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()
Esempio n. 5
0
def given_news_playing(context):
    emit_utterance(context.bus, 'what is the news')
    wait_playback_start(context)
    time.sleep(1)
    context.bus.clear_messages()
Esempio n. 6
0
def given_expired_alarm(context):
    emit_utterance(context.bus, 'set an alarm in 30 seconds')
    time.sleep(30)
Esempio n. 7
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()
Esempio n. 8
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)
Esempio n. 9
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()
Esempio n. 10
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()
Esempio n. 11
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()
Esempio n. 12
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()