|
16 | 16 | # limitations under the License.
|
17 | 17 | #
|
18 | 18 |
|
19 |
| -import string |
20 | 19 | import sys
|
21 |
| -from dataclasses import dataclass |
22 |
| - |
23 |
| -import chip.clusters as Clusters |
24 |
| -from chip.clusters import Attribute |
25 |
| -from MockTestRunner import MockTestRunner |
26 |
| - |
27 |
| -c = Clusters.IcdManagement |
28 |
| -attr = c.Attributes |
29 |
| -uat = c.Bitmaps.UserActiveModeTriggerBitmap |
30 |
| - |
31 |
| - |
32 |
| -@dataclass |
33 |
| -class ICDMData(): |
34 |
| - FeatureMap: int |
35 |
| - IdleModeDuration: int |
36 |
| - ActiveModeDuration: int |
37 |
| - ActiveModeThreshold: int |
38 |
| - RegisteredClients: list |
39 |
| - ICDCounter: int |
40 |
| - ClientsSupportedPerFabric: int |
41 |
| - UserActiveModeTriggerHint: int |
42 |
| - UserActiveModeTriggerInstruction: string |
43 |
| - OperatingMode: c.Enums.OperatingModeEnum |
44 |
| - MaximumCheckInBackOff: int |
45 |
| - expect_pass: bool |
46 | 20 |
|
| 21 | +from common_icdm_data import ICDMData, c, run_tests, uat |
47 | 22 |
|
48 | 23 | long_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut e"
|
49 | 24 | too_long_string = long_string + "1"
|
@@ -217,35 +192,11 @@ class ICDMData():
|
217 | 192 | ]
|
218 | 193 |
|
219 | 194 |
|
220 |
| -def test_spec_to_attribute_cache(test_icdm: ICDMData) -> Attribute.AsyncReadTransaction.ReadResponse: |
221 |
| - resp = Attribute.AsyncReadTransaction.ReadResponse({}, [], {}) |
222 |
| - resp.attributes = {0: {c: {attr.FeatureMap: test_icdm.FeatureMap, attr.IdleModeDuration: test_icdm.IdleModeDuration, attr.ActiveModeDuration: test_icdm.ActiveModeDuration, attr.ActiveModeThreshold: test_icdm.ActiveModeThreshold, |
223 |
| - attr.RegisteredClients: test_icdm.RegisteredClients, attr.ICDCounter: test_icdm.ICDCounter, |
224 |
| - attr.ClientsSupportedPerFabric: test_icdm.ClientsSupportedPerFabric, attr.UserActiveModeTriggerHint: test_icdm.UserActiveModeTriggerHint, |
225 |
| - attr.UserActiveModeTriggerInstruction: test_icdm.UserActiveModeTriggerInstruction, attr.OperatingMode: test_icdm.OperatingMode, attr.MaximumCheckInBackOff: test_icdm.MaximumCheckInBackOff}}} |
226 |
| - return resp |
227 |
| - |
228 |
| - |
229 | 195 | def main():
|
230 | 196 | pics = {"ICDM.S.A0000": True, "ICDM.S.A0001": True, "ICDM.S.A0002": True, "ICDM.S.A0003": True, "ICDM.S.A0004": True,
|
231 | 197 | "ICDM.S.A0005": True, "ICDM.S.A0006": True, "ICDM.S.A0007": True, "ICDM.S.A0008": True, "ICDM.S.A0009": True, }
|
232 | 198 |
|
233 |
| - test_runner = MockTestRunner( |
234 |
| - 'TC_ICDM_2_1', 'TC_ICDM_2_1', 'test_TC_ICDM_2_1', 0, pics) |
235 |
| - failures = [] |
236 |
| - for idx, t in enumerate(TEST_CASES): |
237 |
| - ok = test_runner.run_test_with_mock_read( |
238 |
| - test_spec_to_attribute_cache(t)) == t.expect_pass |
239 |
| - if not ok: |
240 |
| - failures.append(f"Measured test case failure: {idx} {t}") |
241 |
| - |
242 |
| - test_runner.Shutdown() |
243 |
| - print( |
244 |
| - f"Test of tests: run {len(TEST_CASES)}, test response correct: {len(TEST_CASES) - len(failures)} | test response incorrect: {len(failures)}") |
245 |
| - for f in failures: |
246 |
| - print(f) |
247 |
| - |
248 |
| - return 1 if failures else 0 |
| 199 | + return run_tests(pics, 'TC_ICDM_2_1', TEST_CASES, 'test_TC_ICDM_2_1') |
249 | 200 |
|
250 | 201 |
|
251 | 202 | if __name__ == "__main__":
|
|
0 commit comments