Passed
Pull Request — master (#202)
by Jan
03:22
created

tests_oval_graph.test_commands.test_command_bad_arf   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 38
dl 0
loc 51
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A test_bad_command_json_to_graph_with_verbose() 0 7 1
A test_command_with_bad_arf_file() 0 26 2
A test_bad_command_json_to_graph() 0 6 1
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