|
1
|
|
|
import pytest |
|
2
|
|
|
import tempfile |
|
3
|
|
|
import os |
|
4
|
|
|
import uuid |
|
5
|
|
|
|
|
6
|
|
|
from oval_graph.arf_to_html import ArfToHtml |
|
7
|
|
|
import tests.any_test_help |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
def get_client_arf_to_html(src, rule): |
|
11
|
|
|
return ArfToHtml( |
|
12
|
|
|
["--off-web-browser", tests.any_test_help.get_src(src), rule]) |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
def get_client_arf_to_html_with_define_dest(src, rule): |
|
16
|
|
|
return ArfToHtml( |
|
17
|
|
|
["--out", tests.any_test_help.get_src( |
|
18
|
|
|
os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))), |
|
19
|
|
|
"--off-web-browser", |
|
20
|
|
|
tests.any_test_help.get_src(src), |
|
21
|
|
|
rule]) |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
def try_expection_for_prepare_graph(src, rule, err): |
|
25
|
|
|
client = get_client_arf_to_html(src, rule) |
|
26
|
|
|
rules = {'rules': [rule]} |
|
27
|
|
|
with pytest.raises(Exception, match=err): |
|
28
|
|
|
assert client.prepare_data(rules) |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
def test_prepare_graph_with_non_existent_rule(): |
|
32
|
|
|
src = 'test_data/ssg-fedora-ds-arf.xml' |
|
33
|
|
|
rule = 'non-existent_rule' |
|
34
|
|
|
try_expection_for_prepare_graph(src, rule, '404') |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
def test_prepare_graph_with_not_selected_rule(): |
|
38
|
|
|
src = 'test_data/ssg-fedora-ds-arf.xml' |
|
39
|
|
|
rule = 'xccdf_org.ssgproject.content_rule_package_nis_removed' |
|
40
|
|
|
try_expection_for_prepare_graph(src, rule, 'not selected') |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
def test_prepare_tree(): |
|
44
|
|
|
src = 'test_data/ssg-fedora-ds-arf.xml' |
|
45
|
|
|
rule = 'xccdf_org.ssgproject.content_rule_package_abrt_removed' |
|
46
|
|
|
client = get_client_arf_to_html(src, rule) |
|
47
|
|
|
rules = {'rules': [rule]} |
|
48
|
|
|
results_src = client.prepare_data(rules) |
|
49
|
|
|
tests.any_test_help.compare_results_js(results_src[0]) |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
def test_prepare_tree_and_save_in_defined_destination(): |
|
53
|
|
|
src = 'test_data/ssg-fedora-ds-arf.xml' |
|
54
|
|
|
rule = 'xccdf_org.ssgproject.content_rule_package_abrt_removed' |
|
55
|
|
|
client = get_client_arf_to_html_with_define_dest(src, rule) |
|
56
|
|
|
rules = {'rules': [rule]} |
|
57
|
|
|
results_src = client.prepare_data(rules) |
|
58
|
|
|
tests.any_test_help.compare_results_js(results_src[0]) |
|
59
|
|
|
|