Passed
Pull Request — master (#161)
by Jan
04:20
created

test_command_arf_to_graph   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 143
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 120
dl 0
loc 143
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A tests.test_command_arf_to_graph.test_command_parameter_all() 0 13 1
A tests.test_command_arf_to_graph.test_command_arf_to_graph_with_out_parameter() 0 13 1
A tests.test_command_arf_to_graph.test_bad_command_arf_to_graph() 0 14 1
A tests.test_command_arf_to_graph.test_command_arf_to_graph_with_verbose() 0 15 1
A tests.test_command_arf_to_graph.test_command_parameter_all_and_show_failed_rules() 0 14 1
A tests.test_command_arf_to_graph.test_command_arf_to_graph() 0 15 1
A tests.test_command_arf_to_graph.test_bad_command_arf_to_graph_with_verbose() 0 15 1
A tests.test_command_arf_to_graph.test_inquirer_choice_rule() 0 20 1
1
import subprocess
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
introduced by
import missing from __future__ import absolute_import
Loading history...
2
import os
3
import pytest
4
import tempfile
0 ignored issues
show
Unused Code introduced by
The import tempfile seems to be unused.
Loading history...
introduced by
standard import "import tempfile" should be placed before "import pytest"
Loading history...
5
from readchar import key
6
7
import tests.any_test_help
8
9
10
@pytest.mark.usefixtures("remove_generated_reports_in_root")
11
def test_command_arf_to_graph():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
12
    subprocess.check_call(['python3',
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
13
                           '-m',
14
                           'oval_graph.command_line',
15
                           'arf-to-graph',
16
                           '-o', '.',
17
                           'tests/test_data/ssg-fedora-ds-arf.xml',
18
                           'xccdf_org.ssgproject.content_rule_package_abrt_removed'
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
19
                           ],
20
                          cwd='./')
21
    file_src = tests.any_test_help.find_files(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
22
        "graph-of-xccdf_org.ssgproject.content_rule_package_abrt_removed",
23
        '../')
24
    tests.any_test_help.compare_results_html(file_src[0])
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
25
26
27
@pytest.mark.usefixtures("remove_generated_reports_in_root")
28
def test_command_arf_to_graph_with_verbose():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_command_arf_to_graph_with_verbose" doesn't conform to '[a-z_][a-z0-9_]2,30$' pattern ('[a-z_][a-z0-9_]2,30$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
introduced by
Missing function or method docstring
Loading history...
29
    out = subprocess.check_output(['python3',
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
30
                                   '-m',
31
                                   'oval_graph.command_line',
32
                                   'arf-to-graph',
33
                                   '-o', '.',
34
                                   '--verbose',
35
                                   'tests/test_data/ssg-fedora-ds-arf.xml',
36
                                   'xccdf_org.ssgproject.content_rule_package_abrt_removed'
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (91/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
37
                                   ],
38
                                  cwd='./',
39
                                  stderr=subprocess.STDOUT)
40
    src = out.decode('utf-8').split('\n')[-2]
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
41
    tests.any_test_help.compare_results_html('.' + src)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
42
43
44
def test_command_arf_to_graph_with_out_parameter():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_command_arf_to_graph_with_out_parameter" doesn't conform to '[a-z_][a-z0-9_]2,30$' pattern ('[a-z_][a-z0-9_]2,30$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
introduced by
Missing function or method docstring
Loading history...
45
    src = tests.any_test_help.get_random_dir_in_tmp()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
46
    subprocess.check_call(['python3',
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
47
                           '-m',
48
                           'oval_graph.command_line',
49
                           'arf-to-graph',
50
                           '-o',
51
                           src,
52
                           'tests/test_data/ssg-fedora-ds-arf.xml',
53
                           'xccdf_org.ssgproject.content_rule_package_abrt_removed'
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
54
                           ])
55
    tests.any_test_help.compare_results_html(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
56
        os.path.join(src, os.listdir(src)[0]))
57
58
59
def test_inquirer_choice_rule():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
60
    pexpect = pytest.importorskip("pexpect")
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
61
    src = tests.any_test_help.get_random_dir_in_tmp()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
62
    sut = pexpect.spawn('python3',
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
63
                        ['-m',
64
                         'oval_graph.command_line',
65
                         'arf-to-graph',
66
                         '-o',
67
                         src,
68
                         'tests/test_data/ssg-fedora-ds-arf.xml',
69
                         r'_package_\w+_removed'
70
                         ])
71
    sut.expect(r'\w+')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
72
    sut.send(key.DOWN)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
73
    sut.send(key.SPACE)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
74
    sut.send(key.ENTER)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
75
    sut.wait()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
76
    assert len(os.listdir(src)) == 1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
77
    assert ("xccdf_org.ssgproject.content_rule_package_sendmail_removed"
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
78
            in os.listdir(src)[0])
79
80
81
def test_command_parameter_all():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
82
    src = tests.any_test_help.get_random_dir_in_tmp()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
83
    subprocess.check_call(['python3',
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
84
                           '-m',
85
                           'oval_graph.command_line',
86
                           'arf-to-graph',
87
                           '--all',
88
                           '-o',
89
                           src,
90
                           'tests/test_data/ssg-fedora-ds-arf.xml',
91
                           '.'
92
                           ])
93
    assert len(os.listdir(src)) == 184
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
94
95
96
def test_command_parameter_all_and_show_failed_rules():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_command_parameter_all_and_show_failed_rules" doesn't conform to '[a-z_][a-z0-9_]2,30$' pattern ('[a-z_][a-z0-9_]2,30$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
introduced by
Missing function or method docstring
Loading history...
97
    src = tests.any_test_help.get_random_dir_in_tmp()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
98
    subprocess.check_call(['python3',
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
99
                           '-m',
100
                           'oval_graph.command_line',
101
                           'arf-to-graph',
102
                           '--all',
103
                           '--show-failed-rules',
104
                           '-o',
105
                           src,
106
                           'tests/test_data/ssg-fedora-ds-arf.xml',
107
                           r'_package_\w+_removed'
108
                           ])
109
    assert len(os.listdir(src)) == 1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
110
111
112
def test_bad_command_arf_to_graph_with_verbose():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_bad_command_arf_to_graph_with_verbose" doesn't conform to '[a-z_][a-z0-9_]2,30$' pattern ('[a-z_][a-z0-9_]2,30$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
introduced by
Missing function or method docstring
Loading history...
113
    out = subprocess.check_output(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
114
        [
115
            'python3',
116
            '-m',
117
            'oval_graph.command_line',
118
            'arf-to-graph',
119
            '-v',
120
            'tests/test_data/xccdf_org.ssgproject.content_profile_ospp-results-initial.xml',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (92/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
121
            '.'],
122
        stderr=subprocess.STDOUT)
123
    out_string = out.decode('utf-8')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
124
    assert out_string.find("Traceback") > -1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
125
    assert out_string.find("Warning:") > -1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
126
    assert out_string.find("Error:") > -1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
127
128
129
def test_bad_command_arf_to_graph():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
130
    out = subprocess.check_output(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
131
        [
132
            'python3',
133
            '-m',
134
            'oval_graph.command_line',
135
            'arf-to-graph',
136
            'tests/test_data/xccdf_org.ssgproject.content_profile_ospp-results-initial.xml',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (92/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
137
            '.'],
138
        stderr=subprocess.STDOUT)
139
    out_string = out.decode('utf-8')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
140
    assert out_string.find("Traceback") == -1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
141
    assert out_string.find("Warning:") > -1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
142
    assert out_string.find("Error:") > -1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
143