From 89555380d8d710c1153f66e9bf2a4bbecf5373ac Mon Sep 17 00:00:00 2001 From: Kris Gesling Date: Mon, 18 Jan 2021 11:13:54 +0930 Subject: [PATCH] Add VK method to wait for audio service --- .../voight_kampff/__init__.py | 2 +- test/integrationtests/voight_kampff/tools.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/integrationtests/voight_kampff/__init__.py b/test/integrationtests/voight_kampff/__init__.py index a70a3330ab..a14b910eef 100644 --- a/test/integrationtests/voight_kampff/__init__.py +++ b/test/integrationtests/voight_kampff/__init__.py @@ -15,4 +15,4 @@ from .tools import (emit_utterance, wait_for_dialog, then_wait, then_wait_fail, mycroft_responses, - print_mycroft_responses) + print_mycroft_responses, wait_for_audio_service) diff --git a/test/integrationtests/voight_kampff/tools.py b/test/integrationtests/voight_kampff/tools.py index 44dab7e2fb..993952649a 100644 --- a/test/integrationtests/voight_kampff/tools.py +++ b/test/integrationtests/voight_kampff/tools.py @@ -133,3 +133,30 @@ def wait_for_dialog(bus, dialogs, context=None, timeout=None): return bus.new_message_available.wait(0.5) bus.clear_messages() + + +def wait_for_audio_service(context, message_type): + """Wait for audio.service message that matches type provided. + + May be play, stop, or pause messages + + Arguments: + context (behave Context): optional context providing scenario timeout + message_type (string): final component of bus message in form + `mycroft.audio.service.{type} + """ + msg_type = 'mycroft.audio.service.{}'.format(message_type) + + def check_for_msg(message): + return (message.msg_type == msg_type, '') + + passed, debug = then_wait(msg_type, check_for_msg, context) + + if not passed: + debug += mycroft_responses(context) + if not debug: + if message_type == 'play': + message_type = 'start' + debug = "Mycroft didn't {} playback".format(message_type) + + assert passed, debug