@@ 152-175 (lines=24) @@ | ||
149 | return str(FIXTURE_DIR) |
|
150 | ||
151 | ||
152 | def compare_results_html(result): |
|
153 | result_ = any_get_tested_file(result) |
|
154 | reference_pattern = any_get_tested_file( |
|
155 | 'test_data/referenc_pattern_html_report.txt') |
|
156 | prefix_start = '<script>var data_of_tree = ' |
|
157 | prefix_end = ';</script><div>\n' |
|
158 | data_in_html = "" |
|
159 | matched = False |
|
160 | for row in result_: |
|
161 | if prefix_start in row and prefix_end in row: |
|
162 | matched = True |
|
163 | data_in_html = row |
|
164 | assert matched |
|
165 | ||
166 | tmp_json_str = data_in_html.replace(prefix_start, '').replace(prefix_end, '') |
|
167 | tmp_json = json.loads(tmp_json_str) |
|
168 | data_in_html = prefix_start + json.dumps(tmp_json, indent=4, sort_keys=False) + prefix_end |
|
169 | ||
170 | count_row = 0 |
|
171 | rule_name = 'xccdforgssgprojectcontentrulepackageabrtremoved' |
|
172 | for row in reference_pattern: |
|
173 | if row in data_in_html or rule_name in row: |
|
174 | count_row += 1 |
|
175 | assert count_row == len(reference_pattern) |
|
176 | ||
177 | ||
178 | def compare_results_json(result): |
@@ 34-58 (lines=25) @@ | ||
31 | def get_random_dir_in_tmp(): |
|
32 | return os.path.join(tempfile.gettempdir(), str(uuid.uuid4())) |
|
33 | ||
34 | @staticmethod |
|
35 | def compare_results_html(result): |
|
36 | result_ = TestTools.get_text_file(result) |
|
37 | reference_pattern = TestTools.get_text_file( |
|
38 | 'test_commands/test_data/referenc_pattern_html_report.txt') |
|
39 | prefix_start = '<script>var data_of_tree = ' |
|
40 | prefix_end = ';</script><div>\n' |
|
41 | data_in_html = "" |
|
42 | matched = False |
|
43 | for row in result_: |
|
44 | if prefix_start in row and prefix_end in row: |
|
45 | matched = True |
|
46 | data_in_html = row |
|
47 | assert matched |
|
48 | ||
49 | tmp_json_str = data_in_html.replace(prefix_start, '').replace(prefix_end, '') |
|
50 | tmp_json = json.loads(tmp_json_str) |
|
51 | data_in_html = prefix_start + json.dumps(tmp_json, indent=4, sort_keys=False) + prefix_end |
|
52 | ||
53 | count_row = 0 |
|
54 | rule_name = 'xccdforgssgprojectcontentrulepackageabrtremoved' |
|
55 | for row in reference_pattern: |
|
56 | if row in data_in_html or rule_name in row: |
|
57 | count_row += 1 |
|
58 | assert count_row == len(reference_pattern) |
|
59 | ||
60 | @staticmethod |
|
61 | def get_data_json(src): |