Debian Codegraph @

test/contrib/automotive/scanner/configuration.uts

raw
1 % Regression tests for automotive scanner configuration
2
3 + Load general modules
4
5 = Load contribution layer
6
7 from scapy.contrib.automotive.scanner.test_case import AutomotiveTestCase
8 from scapy.contrib.automotive.scanner.configuration import AutomotiveTestCaseExecutorConfiguration
9 from scapy.contrib.automotive.scanner.staged_test_case import StagedAutomotiveTestCase
10
11 + Basic checks
12
13 = Definition of Test classes
14
15 class MyTestCase1(AutomotiveTestCase):
16 _description = "MyTestCase1"
17 def supported_responses(self):
18 return []
19
20
21 class MyTestCase2(AutomotiveTestCase):
22 _description = "MyTestCase2"
23 def supported_responses(self):
24 return []
25
26 class MyTestCase3(AutomotiveTestCase):
27 _description = "MyTestCase3"
28 def supported_responses(self):
29 return []
30
31 class MyTestCase4(AutomotiveTestCase):
32 _description = "MyTestCase4"
33 def supported_responses(self):
34 return []
35
36 = creation of config with classes
37
38 config = AutomotiveTestCaseExecutorConfiguration(
39 [MyTestCase1, MyTestCase2, MyTestCase3, MyTestCase4])
40
41 assert len(config.test_cases) == 4
42 assert len(config.test_case_clss) == 4
43 assert len(config.stages) == 0
44 assert len(config.staged_test_cases) == 0
45 assert config.verbose == False
46 assert config.debug == False
47
48
49 = creation of config with instances
50
51 config = AutomotiveTestCaseExecutorConfiguration(
52 [MyTestCase1(), MyTestCase2(), MyTestCase3(), MyTestCase4()])
53
54 assert len(config.test_cases) == 4
55 assert len(config.test_case_clss) == 4
56 assert len(config.stages) == 0
57 assert len(config.staged_test_cases) == 0
58 assert config.verbose == False
59 assert config.debug == False
60
61
62 = creation of config with instances and classes
63
64 config = AutomotiveTestCaseExecutorConfiguration(
65 [MyTestCase2(), MyTestCase2(), MyTestCase3, MyTestCase4])
66
67 assert len(config.test_cases) == 4
68 assert len(config.test_case_clss) == 3
69 assert len(config.stages) == 0
70 assert len(config.staged_test_cases) == 0
71 assert config.verbose == False
72 assert config.debug == False
73
74
75 = creation of config with instances and classes and global configuration and local configuration
76
77 config = AutomotiveTestCaseExecutorConfiguration(
78 [MyTestCase2(), MyTestCase2(), MyTestCase3, MyTestCase4],
79 global_config=42, verbose=True, MyTestCase2_kwargs={"local_config": 41})
80
81 assert len(config.test_cases) == 4
82 assert len(config.test_case_clss) == 3
83 assert len(config.stages) == 0
84 assert len(config.staged_test_cases) == 0
85 assert config.verbose == True
86 assert config.debug == False
87 assert config["MyTestCase2"]["global_config"] == 42
88 assert config["MyTestCase2"]["local_config"] == 41
89 assert config["MyTestCase2"]["verbose"] == True
90 try:
91 print(config["MyTestCase1"]["global_config"])
92 raise AssertionError
93 except KeyError:
94 pass
95
96 assert len(config["MyTestCase3"]) == 3
97 assert len(config["MyTestCase2"]) == 4
98
99 try:
100 print(config["MyTestCase3"]["local_config"])
101 raise AssertionError
102 except KeyError:
103 pass
104
105
106 = creation of config with stages
107
108 st = StagedAutomotiveTestCase([MyTestCase1(), MyTestCase2()])
109
110 config = AutomotiveTestCaseExecutorConfiguration(
111 [MyTestCase2(), MyTestCase2, MyTestCase3, MyTestCase4, st])
112
113 assert len(config.test_cases) == 5
114 assert len(config.test_case_clss) == 5
115 assert len(config.stages) == 1
116 assert len(config.staged_test_cases) == 2
117 assert config.verbose == False
118 assert config.debug == False
119 assert config.staged_test_cases[0].__class__ == MyTestCase1
120 assert config.staged_test_cases[1].__class__ == MyTestCase2
121 assert config.stages[0].__class__ == StagedAutomotiveTestCase
122
123 = creation of config with stages class
124
125 class myStagedTestCase(StagedAutomotiveTestCase):
126 def __init__(self):
127 # type: () -> None
128 super(myStagedTestCase, self).__init__(
129 [MyTestCase1(), MyTestCase2()],
130 None)
131
132
133 config = AutomotiveTestCaseExecutorConfiguration(
134 [MyTestCase2(), MyTestCase2, MyTestCase3, MyTestCase4, myStagedTestCase])
135
136 assert len(config.test_cases) == 5
137 assert len(config.test_case_clss) == 5
138 assert len(config.stages) == 1
139 assert len(config.staged_test_cases) == 2
140 assert config.staged_test_cases[0].__class__ == MyTestCase1
141 assert config.staged_test_cases[1].__class__ == MyTestCase2
142 assert config.stages[0].__class__ == myStagedTestCase
143 assert config.verbose == False
144 assert config.debug == False