Merge pull request #2618 from MycroftAI/feature/vk-not-reply

Add VK test - specific skill should not reply
pull/2626/head
Kris Gesling 2020-06-22 15:13:37 +09:30 committed by GitHub
commit 200606df62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 2 deletions

View File

@ -14,4 +14,5 @@
#
from .tools import (emit_utterance, wait_for_dialog, then_wait,
mycroft_responses, print_mycroft_responses)
then_wait_fail, mycroft_responses,
print_mycroft_responses)

View File

@ -26,7 +26,8 @@ from behave import given, when, then
from mycroft.messagebus import Message
from mycroft.audio import wait_while_speaking
from test.integrationtests.voight_kampff import mycroft_responses, then_wait
from test.integrationtests.voight_kampff import (mycroft_responses, then_wait,
then_wait_fail)
TIMEOUT = 10
@ -146,6 +147,24 @@ def then_dialog(context, skill, dialog):
assert passed, assert_msg or 'Mycroft didn\'t respond'
@then('"{skill}" should not reply')
def then_do_not_reply(context, skill):
def check_all_dialog(message):
msg_skill = message.data.get('meta').get('skill')
utt = message.data['utterance'].lower()
skill_responded = skill == msg_skill
debug_msg = ("{} responded with '{}'. \n".format(skill, utt)
if skill_responded else '')
return (skill_responded, debug_msg)
passed, debug = then_wait_fail('speak', check_all_dialog, context)
if not passed:
assert_msg = debug
assert_msg += mycroft_responses(context)
assert passed, assert_msg or '{} responded'.format(skill)
@then('"{skill}" should reply with "{example}"')
def then_example(context, skill, example):
skill_path = context.msm.find_skill(skill).path

View File

@ -51,6 +51,23 @@ def then_wait(msg_type, criteria_func, context, timeout=TIMEOUT):
return False, debug
def then_wait_fail(msg_type, criteria_func, context, timeout=TIMEOUT):
"""Wait for a specified time, failing if criteria is fulfilled.
Arguments:
msg_type: message type to watch
criteria_func: Function to determine if a message fulfilling the
test case has been found.
context: behave context
timeout: Time allowance for a message fulfilling the criteria
Returns:
tuple (bool, str) test status and debug output
"""
status, debug = then_wait(msg_type, criteria_func, context, timeout)
return (not status, debug)
def mycroft_responses(context):
"""Collect and format mycroft responses from context.