|
1
|
|
|
import subprocess |
|
2
|
|
|
|
|
3
|
|
|
import pytest |
|
4
|
|
|
|
|
5
|
|
|
COMMAND_START = ['python3', |
|
6
|
|
|
'-m', |
|
7
|
|
|
'oval_graph.command_line' |
|
8
|
|
|
] |
|
9
|
|
|
|
|
10
|
|
|
JSON_TO_GRAPH_COMMAND = [*COMMAND_START, |
|
11
|
|
|
'json-to-graph', |
|
12
|
|
|
'tests_oval_graph/global_test_data/ssg-fedora-ds-arf.xml', |
|
13
|
|
|
'.' |
|
14
|
|
|
] |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
@pytest.mark.parametrize("command_name, optional_args", [ |
|
18
|
|
|
('arf-to-graph', []), |
|
19
|
|
|
('arf-to-json', []), |
|
20
|
|
|
('arf-to-graph', ['-v']), |
|
21
|
|
|
('arf-to-json', ['-v']), |
|
22
|
|
|
]) |
|
23
|
|
|
def test_command_with_bad_arf_file(command_name, optional_args): |
|
24
|
|
|
command = [ |
|
25
|
|
|
*COMMAND_START, |
|
26
|
|
|
command_name, |
|
27
|
|
|
('tests_oval_graph/global_test_data/' |
|
28
|
|
|
'xccdf_org.ssgproject.content_profile_ospp-results-initial.xml'), |
|
29
|
|
|
'.' |
|
30
|
|
|
] |
|
31
|
|
|
command.extend(optional_args) |
|
32
|
|
|
|
|
33
|
|
|
out = subprocess.check_output( |
|
34
|
|
|
command, |
|
35
|
|
|
stderr=subprocess.STDOUT) |
|
36
|
|
|
out_string = out.decode('utf-8') |
|
37
|
|
|
if '-v' in optional_args: |
|
38
|
|
|
assert out_string.find("Traceback") > -1 |
|
39
|
|
|
else: |
|
40
|
|
|
assert out_string.find("Traceback") == -1 |
|
41
|
|
|
assert out_string.find("Warning:") > -1 |
|
42
|
|
|
assert out_string.find("Error:") > -1 |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
def test_bad_command_json_to_graph_with_verbose(): |
|
46
|
|
|
command = [*JSON_TO_GRAPH_COMMAND, '-v'] |
|
47
|
|
|
out = subprocess.check_output(command, |
|
48
|
|
|
stderr=subprocess.STDOUT) |
|
49
|
|
|
out_string = out.decode('utf-8') |
|
50
|
|
|
assert out_string.find("Traceback") > -1 |
|
51
|
|
|
assert out_string.find("Error:") > -1 |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
def test_bad_command_json_to_graph(): |
|
55
|
|
|
out = subprocess.check_output(JSON_TO_GRAPH_COMMAND, |
|
56
|
|
|
stderr=subprocess.STDOUT) |
|
57
|
|
|
out_string = out.decode('utf-8') |
|
58
|
|
|
assert out_string.find("Traceback") == -1 |
|
59
|
|
|
assert out_string.find("Error:") > -1 |
|
60
|
|
|
|