Total Complexity | 3 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # Copyright 2022, Red Hat, Inc. |
||
2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
||
3 | |||
4 | import json |
||
5 | |||
6 | import pytest |
||
7 | from jsonschema import validate |
||
8 | |||
9 | from openscap_report.debug_settings import DebugSetting |
||
10 | from openscap_report.report_generators.json import JSONReportGenerator |
||
11 | from tests.unit_tests.test_data_structure import get_parser, get_report |
||
12 | |||
13 | from ..constants import PATH_TO_ARF, PATH_TO_JSON_SCHEMA |
||
14 | |||
15 | |||
16 | @pytest.mark.integration_test |
||
17 | def test_json_structure_with_schema(): |
||
18 | json_schema = None |
||
19 | with open(PATH_TO_JSON_SCHEMA, "r", encoding="utf-8") as schema_file: |
||
20 | json_schema = json.load(schema_file) |
||
21 | json_gen = JSONReportGenerator(get_parser(PATH_TO_ARF)) |
||
22 | json_data = json_gen.generate_report(DebugSetting()).read().decode("utf-8") |
||
23 | validate(json.loads(json_data), json_schema) |
||
24 | |||
25 | |||
26 | @pytest.mark.integration_test |
||
27 | def test_json_count_of_rules(): |
||
28 | report = get_report() |
||
29 | json_dict = report.as_dict_for_default_json() |
||
30 | assert len(json_dict["rules"]) == 714 |
||
31 |