diff --git a/conformance.py b/conformance.py index b6e8895..bf94f55 100644 --- a/conformance.py +++ b/conformance.py @@ -10,6 +10,7 @@ import dab.system import dab.output import dab.version +from util.enforcement_manager import EnforcementManager # Implement the test cases for conformance test. CONFORMANCE_TEST_CASE = [ @@ -119,9 +120,9 @@ ("app-telemetry/stop",f'{{"appId": "{config.apps["youtube"]}"}}', dab.app_telemetry.stop, 200, "Conformance"), ("health-check/get",'{}', dab.health_check.get, 2000, "Conformance"), ("voice/list",'{}', dab.voice.list, 200, "Conformance"), - ("voice/set",f'{{"voiceSystem":{{"name":"{config.va}","enabled":true}}}}', dab.voice.set, 5000, "Conformance"), - ("voice/send-audio",'{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/ladygaga.wav"}',dab.voice.send_audio, 10000, "Conformance"), - ("voice/send-text",f'{{"requestText" : "Play lady Gaga music on YouTube", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, 10000, "Conformance"), + ("voice/set",f'{{"voiceSystem":{{"name":"{EnforcementManager().get_voice_assistant()}","enabled":true}}}}', dab.voice.set, 5000, "Conformance"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/ladygaga.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}',dab.voice.send_audio, 10000, "Conformance"), + ("voice/send-text",f'{{"requestText" : "Play lady Gaga music on YouTube", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, 10000, "Conformance With VA"), ("version",' {}', dab.version.default, 200, "Conformance"), ("system/restart",' {}', dab.system.restart, 30000, "Conformance"), ] diff --git a/dab/app_telemetry.py b/dab/app_telemetry.py index e50ae31..5003316 100644 --- a/dab/app_telemetry.py +++ b/dab/app_telemetry.py @@ -5,7 +5,11 @@ def start(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_start_device_telemetry_response_schema(test_result.response) + try: + dab_response_validator.validate_start_device_telemetry_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -13,6 +17,10 @@ def start(test_result, durationInMs=0,expectedLatencyMs=0): return Default_Validations(test_result, durationInMs, expectedLatencyMs) def stop(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_stop_device_telemetry_response_schema(test_result.response) + try: + dab_response_validator.validate_stop_device_telemetry_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False sleep(0.1) return Default_Validations(test_result, durationInMs, expectedLatencyMs) \ No newline at end of file diff --git a/dab/applications.py b/dab/applications.py index f7a5a97..7141865 100644 --- a/dab/applications.py +++ b/dab/applications.py @@ -1,10 +1,15 @@ from time import sleep from schema import dab_response_validator from dab_tester import YesNoQuestion, Default_Validations +from util.enforcement_manager import EnforcementManager import jsons def launch(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_dab_response_schema(test_result.response) + try: + dab_response_validator.validate_dab_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -13,6 +18,11 @@ def launch(test_result, durationInMs=0,expectedLatencyMs=0): def launch_with_content(test_result, durationInMs=0,expectedLatencyMs=0): dab_response_validator.validate_dab_response_schema(test_result.response) + try: + dab_response_validator.validate_dab_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -20,7 +30,11 @@ def launch_with_content(test_result, durationInMs=0,expectedLatencyMs=0): return YesNoQuestion(test_result, "App started with playback?") and Default_Validations(test_result, durationInMs, expectedLatencyMs) def exit(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_exit_application_response_schema(test_result.response) + try: + dab_response_validator.validate_exit_application_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -28,15 +42,25 @@ def exit(test_result, durationInMs=0,expectedLatencyMs=0): return YesNoQuestion(test_result, "App exited?") and Default_Validations(test_result, durationInMs, expectedLatencyMs) def list(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_list_applications_response_schema(test_result.response) + try: + dab_response_validator.validate_list_applications_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False + for application in response['applications']: + EnforcementManager().add_supported_application(application['appId']) sleep(0.1) return Default_Validations(test_result, durationInMs, expectedLatencyMs) def get_state(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_get_application_state_response_schema(test_result.response) + try: + dab_response_validator.validate_get_application_state_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/dab/device.py b/dab/device.py index a0caab0..036c87d 100644 --- a/dab/device.py +++ b/dab/device.py @@ -4,7 +4,11 @@ import jsons def info(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_device_information_schema(test_result.response) + try: + dab_response_validator.validate_device_information_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/dab/device_telemetry.py b/dab/device_telemetry.py index 64256c4..d8f01b0 100644 --- a/dab/device_telemetry.py +++ b/dab/device_telemetry.py @@ -4,7 +4,11 @@ import jsons def start(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_start_device_telemetry_response_schema(test_result.response) + try: + dab_response_validator.validate_start_device_telemetry_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -12,7 +16,11 @@ def start(test_result, durationInMs=0,expectedLatencyMs=0): return Default_Validations(test_result, durationInMs, expectedLatencyMs) def stop(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_stop_device_telemetry_response_schema(test_result.response) + try: + dab_response_validator.validate_stop_device_telemetry_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/dab/health_check.py b/dab/health_check.py index 2995e9e..46acdd4 100644 --- a/dab/health_check.py +++ b/dab/health_check.py @@ -4,7 +4,11 @@ import jsons def get(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_health_check_response_schema(test_result.response) + try: + dab_response_validator.validate_health_check_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/dab/input.py b/dab/input.py index 9a31f40..6355a0c 100644 --- a/dab/input.py +++ b/dab/input.py @@ -7,7 +7,11 @@ class KeyList: key_list = [] def key_press(test_result, durationInMs=0, expectedLatencyMs=None): - dab_response_validator.validate_dab_response_schema(test_result.response) + try: + dab_response_validator.validate_dab_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False request = jsons.loads(test_result.request) response = jsons.loads(test_result.response) # No list available, assuming everything is required. @@ -28,7 +32,11 @@ def key_press(test_result, durationInMs=0, expectedLatencyMs=None): return YesNoQuestion(test_result, expectedLatencyMs) def long_key_press(test_result, durationInMs=0, expectedLatencyMs=None): - dab_response_validator.validate_dab_response_schema(test_result.response) + try: + dab_response_validator.validate_dab_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False request = jsons.loads(test_result.request) response = jsons.loads(test_result.response) # No list available, assuming everything is required. @@ -50,7 +58,11 @@ def long_key_press(test_result, durationInMs=0, expectedLatencyMs=None): return YesNoQuestion(test_result, expectedLatencyMs) def list(test_result, durationInMs=0, expectedLatencyMs=0): - dab_response_validator.validate_key_list_schema(test_result.response) + try: + dab_response_validator.validate_key_list_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/dab/operations.py b/dab/operations.py index 4e052c4..c19e854 100644 --- a/dab/operations.py +++ b/dab/operations.py @@ -2,11 +2,18 @@ from time import sleep from dab_tester import YesNoQuestion, Default_Validations import jsons +from util.enforcement_manager import EnforcementManager def list(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_list_supported_operation_response_schema(test_result.response) + try: + dab_response_validator.validate_list_supported_operation_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False + for operation in response['operations']: + EnforcementManager().add_supported_operation(operation) sleep(0.1) return Default_Validations(test_result, durationInMs, expectedLatencyMs) diff --git a/dab/output.py b/dab/output.py index 63467ff..4fb8878 100644 --- a/dab/output.py +++ b/dab/output.py @@ -4,7 +4,11 @@ import jsons def image(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_output_image_response_schema(test_result.response) + try: + dab_response_validator.validate_output_image_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/dab/system.py b/dab/system.py index b6dab40..de19535 100644 --- a/dab/system.py +++ b/dab/system.py @@ -2,9 +2,14 @@ from dab_tester import YesNoQuestion, Default_Validations import jsons from schema import dab_response_validator +from util.enforcement_manager import EnforcementManager def restart(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_dab_response_schema(test_result.response) + try: + dab_response_validator.validate_dab_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -13,7 +18,11 @@ def restart(test_result, durationInMs=0,expectedLatencyMs=0): return YesNoQuestion(test_result, "Cobalt re-started?") def get(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_get_system_settings_response_schema(test_result.response) + try: + dab_response_validator.validate_get_system_settings_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -21,16 +30,30 @@ def get(test_result, durationInMs=0,expectedLatencyMs=0): return Default_Validations(test_result, durationInMs, expectedLatencyMs) def set(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_set_system_settings_response_schema(test_result.response) + try: + dab_response_validator.validate_set_system_settings_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) + request = jsons.loads(test_result.request) + for setting in request: + if not EnforcementManager().is_setting_supported(setting): + if response['status'] != 501: + return False if response['status'] != 200: return False sleep(0.1) return Default_Validations(test_result, durationInMs, expectedLatencyMs) def list(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_list_system_settings_schema(test_result.response) + try: + dab_response_validator.validate_list_system_settings_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) + EnforcementManager().set_supported_settings(response) if response['status'] != 200: return False sleep(0.1) diff --git a/dab/version.py b/dab/version.py index 3402eda..3c9b2d8 100644 --- a/dab/version.py +++ b/dab/version.py @@ -4,7 +4,11 @@ import jsons def default(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_version_response_schema(test_result.response) + try: + dab_response_validator.validate_version_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/dab/voice.py b/dab/voice.py index 9331bc2..e3a8606 100644 --- a/dab/voice.py +++ b/dab/voice.py @@ -2,9 +2,14 @@ from time import sleep from dab_tester import YesNoQuestion, Default_Validations import jsons +from util.enforcement_manager import EnforcementManager def send_audio(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_dab_response_schema(test_result.response) + try: + dab_response_validator.validate_dab_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -15,7 +20,11 @@ def send_audio(test_result, durationInMs=0,expectedLatencyMs=0): return YesNoQuestion(test_result, expectedLatencyMs) def send_text(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_dab_response_schema(test_result.response) + try: + dab_response_validator.validate_dab_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False @@ -26,15 +35,24 @@ def send_text(test_result, durationInMs=0,expectedLatencyMs=0): return YesNoQuestion(test_result, expectedLatencyMs) def list(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_list_voice_response_schema(test_result.response) + try: + dab_response_validator.validate_list_voice_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False + EnforcementManager().add_supported_voice_assistant(response.voiceSystems) sleep(0.1) return Default_Validations(test_result, durationInMs, expectedLatencyMs) def set(test_result, durationInMs=0,expectedLatencyMs=0): - dab_response_validator.validate_set_voice_system_response_schema(test_result.response) + try: + dab_response_validator.validate_set_voice_system_response_schema(test_result.response) + except Exception as error: + print("Schema error:", error) + return False response = jsons.loads(test_result.response) if response['status'] != 200: return False diff --git a/end_to_end_cobalt.py b/end_to_end_cobalt.py index 7792a91..7da95ab 100644 --- a/end_to_end_cobalt.py +++ b/end_to_end_cobalt.py @@ -3,10 +3,12 @@ import dab.input import dab.voice import config +from util.enforcement_manager import EnforcementManager # Voice action steps END_TO_END_TEST_CASE = [ - ("voice/send-text",'{"requestText" : "Play lady Gaga music on YouTube", "voiceSystem": "Alexa"}', dab.voice.send_text, "Are you on search page with Lady Gaga?", "End to end launch"), + ("voice/list",'{}', dab.voice.list, 200, "Voice List"), + ("voice/send-text",f'{{"requestText" : "Play lady Gaga music on YouTube", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Are you on search page with Lady Gaga?", "End to end launch"), ("input/key-press",'{"keyCode": "KEY_ENTER"}', dab.input.key_press, "Is video playing?", "End to end key press Enter"), ("input/long-key-press",'{"keyCode": "KEY_VOLUME_UP", "durationMs": 3000}', dab.input.long_key_press, "Is volume going up?", "End to end volume up"), ("input/long-key-press",'{"keyCode": "KEY_VOLUME_DOWN", "durationMs": 2000}', dab.input.long_key_press, "Is volume going down?", "End to End volume down"), diff --git a/requirements.txt b/requirements.txt index 584b33c..225ea45 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ paho-mqtt == 1.6.1 readchar FileCache jsons -jsonschema \ No newline at end of file +jsonschema +singleton_decorator \ No newline at end of file diff --git a/schema.py b/schema.py index 1713500..28f3b2f 100644 --- a/schema.py +++ b/schema.py @@ -273,55 +273,75 @@ "audioOutputSource", "videoInputSource", "audioVolume", "mute", "textToSpeech"] } +system_settings_schema = { + "language": {"type": "string"}, + "outputResolution": output_resolution_schema, + "memc": {"type": "boolean"}, + "cec": {"type": "boolean"}, + "lowLatencyMode": {"type": "boolean"}, + "matchContentFrameRate": {"type": "string"}, + "hdrOutputMode": {"type": "string"}, + "pictureMode": {"type": "string"}, + "audioOutputMode": {"type": "string"}, + "audioOutputSource": {"type": "string"}, + "videoInputSource": {"type": "string"}, + "audioVolume": {"type": "integer"}, + "mute": {"type": "boolean"}, + "textToSpeech": {"type": "boolean"}, +} + # Operation: system/settings/get # GetSystemSettingsResponse get_system_settings_response_schema = { "type": "object", "properties": { - "status": {"type": "integer"}, - "error": {"type": ["string", "null"]}, - "language": {"type": "string"}, - "outputResolution": output_resolution_schema, - "memc": {"type": "boolean"}, - "cec": {"type": "boolean"}, - "lowLatencyMode": {"type": "boolean"}, - "matchContentFrameRate": {"type": "string"}, - "hdrOutputMode": {"type": "string"}, - "pictureMode": {"type": "string"}, - "audioOutputMode": {"type": "string"}, - "audioOutputSource": {"type": "string"}, - "videoInputSource": {"type": "string"}, - "audioVolume": {"type": "integer"}, - "mute": {"type": "boolean"}, - "textToSpeech": {"type": "boolean"}, + "status": {"type": "integer"} }, - "required": ["status", "language", "outputResolution", "memc", "cec", "lowLatencyMode", - "matchContentFrameRate", "hdrOutputMode", "pictureMode", "audioOutputMode", - "audioOutputSource", "videoInputSource", "audioVolume", "mute", "textToSpeech"] + "required": ["status"], + + "if": { + "properties": { + "status": { "const": 200 } + } + }, + "then": { + "properties": system_settings_schema, + "required": list(system_settings_schema.keys()) + }, + "else": { + "properties": { + "error": {"type": ["string", "null"]} + }, + "required": ["error"] + }, + + "unevaluatedProperties": False } # SetSystemSettingsResponse set_system_settings_response_schema = { "type": "object", "properties": { - "status": {"type": "integer"}, - "error": {"type": ["string", "null"]}, - "language": {"type": "string"}, - "outputResolution": output_resolution_schema, - "memc": {"type": "boolean"}, - "cec": {"type": "boolean"}, - "lowLatencyMode": {"type": "boolean"}, - "matchContentFrameRate": {"type": "string"}, - "hdrOutputMode": {"type": "string"}, - "pictureMode": {"type": "string"}, - "audioOutputMode": {"type": "string"}, - "audioOutputSource": {"type": "string"}, - "videoInputSource": {"type": "string"}, - "audioVolume": {"type": "integer"}, - "mute": {"type": "boolean"}, - "textToSpeech": {"type": "boolean"}, + "status": {"type": "integer"} }, - "required": ["status"] + "required": ["status"], + + "if": { + "properties": { + "status": { "const": 200 } + } + }, + "then": { + "properties": system_settings_schema + }, + "else": { + "properties": { + "error": {"type": ["string", "null"]} + }, + "required": ["error"] + }, + + "unevaluatedProperties": False } # Operation: input/key/list diff --git a/util/enforcement_manager.py b/util/enforcement_manager.py new file mode 100644 index 0000000..fbdd039 --- /dev/null +++ b/util/enforcement_manager.py @@ -0,0 +1,83 @@ +from singleton_decorator import singleton +from typing import List + +class Resolution: + width: int + height: int + frequency: int + +class Settings: + status: int + language: List[str] + outputResolution: List[Resolution] + memc: bool + cec: bool + lowLatencyMode: bool + matchContentFrameRate: List[str] + hdrOutputMode: List[str] + pictureMode: List[str] + audioOutputMode: List[str] + audioOutputSource: List[str] + videoInputSource: List[str] + audioVolume: bool + mute: bool + textToSpeech: bool + +@singleton +class EnforcementManager: + def __init__(self): + self.supported_operations = set() + self.supported_keys = set() + self.supported_voice_assistants = set() + self.supported_settings = None + self.supported_applications = set() + + def add_supported_operation(self, operation): + self.supported_operations.add(operation) + + def is_operation_supported(self, operation): + return not self.supported_operations or operation in self.supported_operations + + def add_supported_key(self, key): + self.supported_keys.add(key) + + def is_key_supported(self, key): + return not self.supported_keys or key in self.supported_keys + + def add_supported_voice_assistant(self, voice_assistant): + self.supported_voice_assistants.add(voice_assistant) + + def is_voice_assistant_supported(self, voice_assistant): + return not self.supported_voice_assistants or voice_assistant in self.supported_voice_assistants + + def get_voice_assistant(self): + return "AmazonAlexa" if len(self.supported_voice_assistants) == 0 else self.supported_voice_assistants[0] + + def set_supported_settings(self, settings): + self.supported_settings = settings + + def is_setting_supported(self, setting): + """ + Checks if a setting is supported by the target. + + Args: + setting: The name of the setting. + + Returns: + True if the setting is supported, False otherwise. + """ + + if not self.supported_settings: + return True + + if isinstance(self.supported_settings.get(setting), List) and len(self.supported_settings.get(setting)) == 0: + return True + + if isinstance(self.supported_settings.get(setting), bool) and self.supported_settings.get(setting): + return True + + def add_supported_application(self, application): + self.supported_applications.add(application) + + def is_application_supported(self, application): + return not self.supported_applications or application in self.supported_applications \ No newline at end of file diff --git a/voice_audio.py b/voice_audio.py index f2bd49d..60c92ea 100644 --- a/voice_audio.py +++ b/voice_audio.py @@ -1,17 +1,18 @@ import dab.applications import dab.system import dab.voice -import config +from util.enforcement_manager import EnforcementManager # Voice action steps SEND_VOICE_AUDIO_TEST_CASES = [ - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/ladygaga.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Are you on search page with Lady Gaga?", "Voice launch Lady gaga"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/pressenter.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Is video playing?", "Voice play video"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/playvideo.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "If video was not playing, is it playing now?", "Voice resume video"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/setvolume0.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Did volume of the video changed?", "voice mute"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/setvolume5.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Did volume of the video changed?", "voice volume up"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/pausevideo.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Did video paused?", "voice pause"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/fastforwardvideo.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Did video playback fast forward?", "voice fastforward"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/rewindvideo.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Did video playback rewind?", "voice rewind"), - ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/exittomainmenu.wav", "voiceSystem": "{config.va}"}}', dab.voice.send_audio, "Are you on main menu?", "voice exit"), -] + ("voice/list",'{}', dab.voice.list, 200, "Voice List"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/ladygaga.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Are you on search page with Lady Gaga?", "Voice launch Lady gaga"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/pressenter.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Is video playing?", "Voice play video"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/playvideo.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "If video was not playing, is it playing now?", "Voice resume video"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/setvolume0.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Did volume of the video changed?", "voice mute"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/setvolume5.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Did volume of the video changed?", "voice volume up"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/pausevideo.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Did video paused?", "voice pause"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/fastforwardvideo.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Did video playback fast forward?", "voice fastforward"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/rewindvideo.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Did video playback rewind?", "voice rewind"), + ("voice/send-audio",f'{{"fileLocation": "https://storage.googleapis.com/ytlr-cert.appspot.com/voice/exittomainmenu.wav", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_audio, "Are you on main menu?", "voice exit"), +] \ No newline at end of file diff --git a/voice_text.py b/voice_text.py index 5c5479f..6e6646a 100644 --- a/voice_text.py +++ b/voice_text.py @@ -1,17 +1,18 @@ import dab.applications import dab.system import dab.voice -import config +from util.enforcement_manager import EnforcementManager # Voice action steps SEND_VOICE_TEXT_TEST_CASES = [ - ("voice/send-text", f'{{"requestText" : "Play lady Gaga music on YouTube", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Are you on search page with Lady Gaga?", "Voice launch Lady gaga"), - ("voice/send-text", f'{{"requestText" : "Press enter", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Is video playing?", "Voice play video"), - ("voice/send-text", f'{{"requestText" : "Play video", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "If video was not playing, is it playing now?", "Voice resume video"), - ("voice/send-text", f'{{"requestText" : "Set volume 0", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Did volume of the video changed?", "voice mute"), - ("voice/send-text", f'{{"requestText" : "Set volume 5", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Did volume of the video changed?", "voice volume up"), - ("voice/send-text", f'{{"requestText" : "Pause Video", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Did video paused?", "voice pause"), - ("voice/send-text", f'{{"requestText" : "Fast forward video", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Did video playback fast forward?", "voice fastforward"), - ("voice/send-text", f'{{"requestText" : "Rewind video", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Did video playback rewind?", "voice rewind"), - ("voice/send-text", f'{{"requestText" : "Exit to main menu", "voiceSystem" : "{config.va}"}}', dab.voice.send_text, "Are you on main menu?", "voice exit"), + ("voice/list",'{}', dab.voice.list, 200, "Voice List"), + ("voice/send-text",f'{{"requestText" : "Play lady Gaga music on YouTube", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Are you on search page with Lady Gaga?", "Voice launch Lady gaga"), + ("voice/send-text",f'{{"requestText" : "Press enter", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Is video playing?", "Voice play video"), + ("voice/send-text",f'{{"requestText" : "Play video", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "If video was not playing, is it playing now?", "Voice resume video"), + ("voice/send-text",f'{{"requestText" : "Set volume 0", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Did volume of the video changed?", "voice mute"), + ("voice/send-text",f'{{"requestText" : "Set volume 5", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Did volume of the video changed?", "voice volume up"), + ("voice/send-text",f'{{"requestText" : "Pause Video", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Did video paused?", "voice pause"), + ("voice/send-text",f'{{"requestText" : "Fast forward video", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Did video playback fast forward?", "voice fastforward"), + ("voice/send-text",f'{{"requestText" : "Rewind video", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Did video playback rewind?", "voice rewind"), + ("voice/send-text",f'{{"requestText" : "Exit to main menu", "voiceSystem": "{EnforcementManager().get_voice_assistant()}"}}', dab.voice.send_text, "Are you on main menu?", "voice exit"), ] \ No newline at end of file