1
|
|
|
import pytest |
2
|
|
|
import tempfile |
3
|
|
|
import os |
4
|
|
|
import uuid |
5
|
|
|
import mock |
6
|
|
|
import sys |
7
|
|
|
|
8
|
|
|
from oval_graph.command_line_client.arf_to_html_report import ArfToHtmlReport |
9
|
|
|
import tests.any_test_help |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
def get_client_arf_to_html(src): |
13
|
|
|
return ArfToHtmlReport([tests.any_test_help.get_src(src)]) |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
def get_client_arf_to_html_with_define_dest(src): |
17
|
|
|
return ArfToHtmlReport( |
18
|
|
|
["--output", tests.any_test_help.get_src( |
19
|
|
|
os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))), |
20
|
|
|
tests.any_test_help.get_src(src) |
21
|
|
|
]) |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
def try_expection_for_prepare_graph(src, err): |
25
|
|
|
with pytest.raises(Exception, match=err): |
26
|
|
|
client = get_client_arf_to_html(src) |
27
|
|
|
rules = {'rules': ['.']} |
28
|
|
|
assert client.prepare_data(rules) |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
def test_prepare_report_with_bad_file(): |
32
|
|
|
src = 'test_data/xccdf_org.ssgproject.content_profile_ospp-results-initial.xml' |
33
|
|
|
|
34
|
|
|
try_expection_for_prepare_graph(src,'not arf report') |
35
|
|
|
|
36
|
|
|
@pytest.mark.usefixtures("remove_generated_reports_in_root") |
37
|
|
|
def test_prepare_report(): |
38
|
|
|
src = 'test_data/ssg-fedora-ds-arf.xml' |
39
|
|
|
client = get_client_arf_to_html(src) |
40
|
|
|
rules = {'rules': ['.']} |
41
|
|
|
results_src = client.prepare_data(rules) |
42
|
|
|
client.kill_web_browsers() |
43
|
|
|
assert os.path.exists(results_src[0]) |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
def test_prepare_report_and_save_in_defined_destination(): |
47
|
|
|
src = 'test_data/ssg-fedora-ds-arf.xml' |
48
|
|
|
client = get_client_arf_to_html_with_define_dest(src) |
49
|
|
|
rules = {'rules': ['.']} |
50
|
|
|
results_src = client.prepare_data(rules) |
51
|
|
|
assert os.path.exists(results_src[0]) |
52
|
|
|
|