|
20 | 20 | "programVersion", |
21 | 21 | "reducedHeatingEffect", |
22 | 22 | # self.__device_data related |
23 | | - "firmwareVersion", |
24 | 23 | "lastOnline", |
| 24 | +] |
| 25 | + |
| 26 | +REPEATING_TEST_EXCLUDED_LINE_STRINGS = [ |
25 | 27 | # Register group related |
26 | 28 | "registerValue", |
27 | 29 | "timeStamp", |
28 | 30 | "value", |
29 | 31 | ] |
30 | 32 |
|
31 | 33 |
|
32 | | -def test_excluded_string_in_line(line: str) -> bool: |
33 | | - for excluded_string in TEST_EXCLUDED_LINE_STRINGS: |
34 | | - if excluded_string in line: |
| 34 | +def test_excluded_string_in_lines(line1: str, line2) -> bool: |
| 35 | + if ( |
| 36 | + len(TEST_EXCLUDED_LINE_STRINGS) != 0 |
| 37 | + and TEST_EXCLUDED_LINE_STRINGS[0] in line1 |
| 38 | + and TEST_EXCLUDED_LINE_STRINGS[0] in line2 |
| 39 | + ): |
| 40 | + del TEST_EXCLUDED_LINE_STRINGS[0] |
| 41 | + return True |
| 42 | + |
| 43 | + for excluded_string in REPEATING_TEST_EXCLUDED_LINE_STRINGS: |
| 44 | + if excluded_string in line1 and excluded_string in line2: |
35 | 45 | return True |
| 46 | + |
36 | 47 | return False |
37 | 48 |
|
38 | 49 |
|
@@ -67,19 +78,17 @@ def test_excluded_string_in_line(line: str) -> bool: |
67 | 78 | f"{absolute_path}/../ThermiaOnlineAPI/tests/debug_files/diplomat_duo_921.txt" |
68 | 79 | ) |
69 | 80 |
|
70 | | -with open("debug.txt", "r") as f: |
| 81 | +with open(existing_data_filename, "r") as f: |
71 | 82 | existing_debug_data = f.read() |
72 | 83 |
|
73 | | -for [existing_line, new_line] in zip( |
74 | | - existing_debug_data.split("\n"), debug_data.split("\n") |
| 84 | +for [idx, [existing_line, new_line]] in enumerate( |
| 85 | + zip(existing_debug_data.split("\n"), debug_data.split("\n")) |
75 | 86 | ): |
76 | | - if test_excluded_string_in_line(existing_line) and test_excluded_string_in_line( |
77 | | - new_line |
78 | | - ): |
| 87 | + if test_excluded_string_in_lines(existing_line, new_line): |
79 | 88 | continue |
80 | 89 |
|
81 | 90 | if existing_line != new_line: |
82 | | - print("Existing data does not match new data") |
| 91 | + print("Existing data does not match new data on line " + str(idx + 1)) |
83 | 92 | print("Existing line: " + existing_line) |
84 | 93 | print("New line: " + new_line) |
85 | 94 | print("\n") |
|
0 commit comments