forked from device-automation-bus/dab-compliance-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
108 lines (93 loc) · 3.7 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from dab_tester import DabTester
from dab_tester import Default_Validations
from dab_tester import to_test_id
import config
import dab.app_telemetry
import dab.device
import dab.health_check
import dab.input
import dab.operations
import dab.device_telemetry
import dab.voice
import dab.applications
import dab.system
import dab.output
import dab.version
import argparse
import conformance
import end_to_end_cobalt
import voice_audio
import voice_text
import output_image
import netflix
ALL_SUITES = {
"conformance": conformance.CONFORMANCE_TEST_CASE,
"end_to_end_cobalt": end_to_end_cobalt.END_TO_END_TEST_CASE,
"voice_audio": voice_audio.SEND_VOICE_AUDIO_TEST_CASES,
"voice_text": voice_text.SEND_VOICE_TEXT_TEST_CASES,
"output_image": output_image.OUTPUT_IMAGE_TEST_CASES,
"netflix": netflix.NETFLIX_TEST_CASES
}
if __name__ == "__main__":
test_suites_str = ""
for field_name in ALL_SUITES.keys():
test_suites_str += field_name + ", "
test_suites_str = test_suites_str[:-2]
parser = argparse.ArgumentParser()
parser.add_argument("-v","--verbose",
help="increase output verbosity",
action="store_true")
parser.set_defaults(verbose=False)
parser.add_argument("-l","--list",
help="list the test cases",
action="store_true")
parser.set_defaults(list=False)
parser.add_argument("-b","--broker",
help="set the IP of the MQTT broker. Ex: -b 192.168.0.100",
type=str,
default="localhost")
parser.add_argument("-I","--ID",
help="set the DAB Device ID. Ex: -I mydevice123",
type=str,
default="localhost")
parser.add_argument("-c","--case",
help="test only the specified case. Ex: -c InputLongKeyPressKeyDown",
type=str)
parser.add_argument("-o","--output",
help="output location for the json file",
type=str)
parser.add_argument("-s","--suite",
help="set what test suite to run. Available test suite includes:" + test_suites_str,
type=str)
parser.set_defaults(output="")
parser.set_defaults(case=99999)
args = parser.parse_args()
# Use the DabTester
device_id = args.ID
Tester = DabTester(args.broker)
Tester.verbose = args.verbose
suite_to_run = {}
if (args.suite):
# Let dict throw KeyError here
suite_to_run.update({args.suite: ALL_SUITES[args.suite]})
else:
suite_to_run = ALL_SUITES
if(args.list == True):
for suite in suite_to_run:
for test_case in suite_to_run[suite]:
(dab_request_topic, dab_request_body, validate_output_function, expected_response, test_title) = test_case
print(to_test_id(f"{dab_request_topic}/{test_title}"))
else:
if ((not isinstance(args.case, (str)) or len(args.case) == 0)):
# Test all the cases
print("Testing all cases")
for suite in suite_to_run:
Tester.Execute_All_Tests(suite, device_id, suite_to_run[suite], args.output)
else:
# Test a single case
for suite in suite_to_run:
for test_case in suite_to_run[suite]:
(dab_request_topic, dab_request_body, validate_output_function, expected_response, test_title) = test_case
if (to_test_id(f"{dab_request_topic}/{test_title}") == args.case):
Tester.Execute_Test_Case(device_id,(test_case))
Tester.Close()