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

tests.any_test_help   B

Complexity

Total Complexity 48

Size/Duplication

Total Lines 249
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 183
dl 0
loc 249
rs 8.5599
c 0
b 0
f 0
wmc 48

26 Functions

Rating   Name   Duplication   Size   Complexity  
A get_dict_of_simple_tree() 0 2 1
B any_test_treeEvaluation() 0 21 8
A if_not_installed_inquirer_with_option_show_not_selected_rules_and_show_failed_rules() 0 5 1
B compare_results_html() 0 15 7
A compare_results_json() 0 10 1
A if_not_installed_inquirer_with_option_show_not_selected_rules() 0 11 2
A any_test_create_node_dict_for_JsTree() 0 5 2
A _find_all_in_string() 0 2 1
A get_random_dir_in_tmp() 0 2 1
A any_test_parsing_and_evaluate_scan_rule() 0 4 1
A get_Converter_simple_tree() 0 2 1
A any_test_tree_to_dict_of_tree() 0 2 1
A any_test_transformation_tree_to_Json_for_JsTree() 0 10 1
A get_simple_tree() 0 30 1
A find_files() 0 7 4
A any_get_test_data_json() 0 3 2
A any_test_dict_to_tree() 0 3 1
A get_questions_not_selected_and_show_failed_rules() 0 7 1
A get_src() 0 4 1
A find_any_node() 0 3 1
A get_questions_with_option_show_failed_rules() 0 6 2
A get_questions_not_selected() 0 11 1
A any_get_tested_file() 0 3 2
A any_test_treeEvaluation_with_tree() 0 2 1
A if_not_installed_inquirer_with_option_show_failed_rules() 0 8 2
A get_parser() 0 2 1

How to fix   Complexity   

Complexity

Complex classes like tests.any_test_help often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
import os
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
introduced by
import missing from __future__ import absolute_import
Loading history...
2
import json
3
import sys
4
import mock
5
import pytest
6
import uuid
0 ignored issues
show
introduced by
standard import "import uuid" should be placed before "import mock"
Loading history...
7
import tempfile
0 ignored issues
show
introduced by
standard import "import tempfile" should be placed before "import mock"
Loading history...
8
import re
0 ignored issues
show
introduced by
standard import "import re" should be placed before "import mock"
Loading history...
9
10
from oval_graph.oval_node import restore_dict_to_tree, OvalNode
11
from oval_graph.converter import Converter
12
from oval_graph.xml_parser import XmlParser
13
14
15
def any_test_treeEvaluation(tree, expect, file_name=None):
0 ignored issues
show
Coding Style Naming introduced by
Function name "any_test_treeEvaluation" 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...
16
    if file_name is not None and tree is None:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
17
        if file_name.startswith('AND'):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
18
            dir = 'test_data_and'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in dir.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
19
        elif file_name.startswith('OR'):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
20
            dir = 'test_data_or'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
21
        elif file_name.startswith('XOR'):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
22
            dir = 'test_data_xor'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
23
        elif file_name.startswith('ONE'):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
24
            dir = 'test_data_one'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
25
        else:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
26
            dir = 'test_data_NONE'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
27
28
        src = 'test_data/' + dir + '/' + file_name
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
29
        data = dict()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
30
        with open(get_src(src), "r") as f:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
Coding Style Naming introduced by
Variable name "f" 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...
31
            data = json.load(f)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
32
        assert restore_dict_to_tree(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
33
            data).evaluate_tree() == expect
34
    else:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
35
        assert tree.evaluate_tree() == expect
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
36
37
38
def any_test_parsing_and_evaluate_scan_rule(src, rule_id, result):
0 ignored issues
show
Coding Style Naming introduced by
Function name "any_test_parsing_and_evaluate_scan_rule" 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...
39
    parser = XmlParser(get_src(src))
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
40
    oval_tree = parser.get_oval_tree(rule_id)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
41
    any_test_treeEvaluation(oval_tree, result)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
42
43
44
def get_random_dir_in_tmp():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
45
    return os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
46
47
48
def any_get_test_data_json(src):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
49
    with open(get_src(src), 'r') as f:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Coding Style Naming introduced by
Variable name "f" 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...
50
        return json.load(f)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
51
52
53
def any_get_tested_file(src):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
54
    with open(get_src(src), 'r') as f:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Coding Style Naming introduced by
Variable name "f" 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...
55
        return f.readlines()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
56
57
58
def get_Converter_simple_tree():
0 ignored issues
show
Coding Style Naming introduced by
Function name "get_Converter_simple_tree" 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...
59
    return Converter(get_simple_tree())
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
60
61
62
def any_test_create_node_dict_for_JsTree(tree, json_src):
0 ignored issues
show
Coding Style Naming introduced by
Function name "any_test_create_node_dict_for_JsTree" 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...
63
    data = dict()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
64
    with open(get_src(json_src), "r") as f:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Coding Style Naming introduced by
Variable name "f" 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...
65
        data = json.load(f)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
66
    assert Converter(tree).to_JsTree_dict() == data
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
67
68
69
def get_simple_tree():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
70
    return OvalNode(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
71
        node_id=1,
72
        node_type='operator',
73
        value='and',
74
        children=[
75
            OvalNode(
76
                node_id=2,
77
                node_type='value',
78
                value='true',
79
            ),
80
            OvalNode(
81
                node_id=3,
82
                node_type='value',
83
                value='false',
84
            ),
85
            OvalNode(
86
                node_id=4,
87
                node_type='operator',
88
                value='or',
89
                children=[
90
                    OvalNode(
91
                        node_id=5,
92
                        node_type='value',
93
                        value='false',
94
                    ),
95
                    OvalNode(
96
                        node_id=6,
97
                        node_type='value',
98
                        value="true",
99
                    ),
100
                ]
101
            )
102
        ]
103
    )
104
105
106
def get_dict_of_simple_tree():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
107
    return get_simple_tree().save_tree_to_dict()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
108
109
110
def any_test_transformation_tree_to_Json_for_JsTree(
0 ignored issues
show
Coding Style Naming introduced by
Function name "any_test_transformation_tree_to_Json_for_JsTree" 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...
111
        src, test_data_src, rule_id):
112
    test_data = any_get_test_data_json(test_data_src)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
113
114
    parser = XmlParser(get_src(src))
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
115
    oval_tree = parser.get_oval_tree(rule_id)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
116
117
    assert oval_tree.node_id == rule_id
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
118
    out_data = Converter(oval_tree).to_JsTree_dict()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
119
    assert out_data == test_data
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
120
121
122
def any_test_tree_to_dict_of_tree(tree, dict_of_tree):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
123
    assert tree.save_tree_to_dict() == dict_of_tree
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
124
125
126
def find_any_node(tree, node_id):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
127
    findTree = tree.find_node_with_ID(node_id)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Coding Style Naming introduced by
Variable name "findTree" 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...
128
    assert findTree.node_id == node_id
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
129
130
131
def any_test_treeEvaluation_with_tree(tree, expect):
0 ignored issues
show
Coding Style Naming introduced by
Function name "any_test_treeEvaluation_with_tree" 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...
132
    assert tree.evaluate_tree() == expect
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
133
134
135
def any_test_dict_to_tree(dict_of_tree):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
136
    treedict_of_tree = restore_dict_to_tree(dict_of_tree)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
137
    assert treedict_of_tree.save_tree_to_dict() == dict_of_tree
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
138
139
140
def get_parser(src):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
141
    return XmlParser(get_src(src))
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
142
143
144
def get_src(src):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
145
    _dir = os.path.dirname(os.path.realpath(__file__))
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
146
    FIXTURE_DIR = os.path.join(_dir, src)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Coding Style Naming introduced by
Variable name "FIXTURE_DIR" 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...
147
    return str(FIXTURE_DIR)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
148
149
150
def compare_results_html(result):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
151
    result_ = any_get_tested_file(result)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
152
    reference_pattern = any_get_tested_file(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
153
        'test_data/referenc_pattern_html_report.txt')
154
    start_pattern = False
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
155
    count_row = 0
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
156
    for row in result_:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
157
        if row == '<script>var data_of_tree = {\n':
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
158
            start_pattern = True
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
159
        if start_pattern and "xccdforgssgprojectcontentrulepackageabrtremoved" in row:
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (86/80).

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

Loading history...
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
160
            row = re.sub(r'[0-9]+', '', row)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
161
        count_row += (1 if start_pattern and row in reference_pattern else 0)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
162
        if row == '};</script><div>\n':
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
163
            break
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
164
    assert count_row == len(reference_pattern)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
165
166
167
def compare_results_json(result):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
168
    result = any_get_test_data_json(result)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
169
    reference_result = any_get_test_data_json(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
170
        'test_data/referenc_result_data_json.json')
171
    rule_name = "xccdf_org.ssgproject.content_rule_package_abrt_removed"
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
172
    result_rule_name = [
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
173
        x for x in result.keys() if re.search(
174
            rule_name, x)]
175
    assert (result[result_rule_name[0]]
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
176
            == reference_result[rule_name])
177
178
179
def _find_all_in_string(regex, count, string):
180
    assert len(re.findall(regex, string)) == count
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
181
182
183
def get_questions_not_selected(capsys, client):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
184
    out = client.get_questions()[0].choices
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
185
    outResult = [
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Coding Style Naming introduced by
Variable name "outResult" 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...
186
        'xccdf_org.ssgproject.content_rule_package_abrt_removed',
187
        'xccdf_org.ssgproject.content_rule_package_sendmail_removed']
188
    assert out == outResult
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
189
    captured = capsys.readouterr()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
190
# Problem with CI when si called function test_arf_to_hml.test_get_question_not_selected
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (88/80).

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

Loading history...
191
# other calls work with ==.
192
    regex = r'rule_package_\w+_removed\(Not selected\)'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
193
    _find_all_in_string(regex, 6, captured.out)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
194
195
196
def get_questions_not_selected_and_show_failed_rules(capsys, client):
0 ignored issues
show
Coding Style Naming introduced by
Function name "get_questions_not_selected_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...
197
    out = client.get_questions()[0].choices
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
198
    outResult = ['xccdf_org.ssgproject.content_rule_package_abrt_removed']
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Coding Style Naming introduced by
Variable name "outResult" 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...
199
    assert out == outResult
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
200
    captured = capsys.readouterr()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
201
    regex = r'rule_package_\w+_removed\(Not selected\)'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
202
    _find_all_in_string(regex, 6, captured.out)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
203
204
205
def get_questions_with_option_show_failed_rules(client):
0 ignored issues
show
Coding Style Naming introduced by
Function name "get_questions_with_option_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...
206
    out = client.get_questions()[0].choices
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
207
    rule1 = 'xccdf_org.ssgproject.content_rule_package_abrt_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
208
    assert out[0] == rule1
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
209
    with pytest.raises(Exception, match="list index out of range"):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
210
        assert out[2] is None
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
211
212
213
def if_not_installed_inquirer_with_option_show_failed_rules(capsys, client):
0 ignored issues
show
Coding Style Naming introduced by
Function name "if_not_installed_inquirer_with_option_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...
214
    with mock.patch.dict(sys.modules, {'inquirer': None}):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
215
        out = client.run_gui_and_return_answers()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
216
        assert out is None
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
217
        captured = capsys.readouterr()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
218
        assert "inquirer" in captured.out
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
219
        regex = r'rule_package_\w+_removed\$'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
220
        _find_all_in_string(regex, 1, captured.out)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
221
222
223
def if_not_installed_inquirer_with_option_show_not_selected_rules(
0 ignored issues
show
Coding Style Naming introduced by
Function name "if_not_installed_inquirer_with_option_show_not_selected_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...
224
        capsys, client, count_of_selected_rule=2):
225
    with mock.patch.dict(sys.modules, {'inquirer': None}):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
226
        out = client.run_gui_and_return_answers()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
227
        assert out is None
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
228
        captured = capsys.readouterr()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
229
        assert "inquirer" in captured.out
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
230
        regex = r'rule_package_\w+_removed\$'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
231
        _find_all_in_string(regex, count_of_selected_rule, captured.out)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
232
        regex = r'rule_package_\w+_removed\(Not selected\)'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
233
        _find_all_in_string(regex, 6, captured.out)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
234
235
236
def if_not_installed_inquirer_with_option_show_not_selected_rules_and_show_failed_rules(
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (88/80).

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

Loading history...
Coding Style Naming introduced by
Function name "if_not_installed_inquirer_with_option_show_not_selected_rules_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...
237
        capsys,
238
        client):
239
    if_not_installed_inquirer_with_option_show_not_selected_rules(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
240
        capsys, client, 1)
241
242
def find_files(file_name, search_path):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
243
    result = []
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
244
    for root, dir_, files in os.walk(search_path):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Unused Code introduced by
The variable dir_ seems to be unused.
Loading history...
245
        for filename in files:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
246
            if file_name in filename:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
247
                result.append(os.path.abspath(os.path.join(root, filename)))
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 16 tabs, expected 4
Loading history...
248
    return result
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
249