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