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

tests.test_arf_to_hml   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 107
dl 0
loc 140
rs 10
c 0
b 0
f 0
wmc 20

16 Functions

Rating   Name   Duplication   Size   Complexity  
A test_prepare_tree() 0 9 1
A get_client_arf_to_html_with_define_dest() 0 6 1
A test_prepare_graph_with_not_selected_rule() 0 4 1
A get_client_arf_to_html() 0 2 1
A test_prepare_graph_with_non_existent_rule() 0 4 1
A get_client_arf_to_html_with_option_show_not_selected_rules_and_show_failed_rules() 0 7 1
A try_expection_for_prepare_graph() 0 5 2
A test_get_questions_with_option_show_failed_rules() 0 5 1
A test_if_not_installed_inquirer_with_option_show_not_selected_rules() 0 9 2
A test_if_not_installed_inquirer_with_option_show_failed_rules() 0 9 2
A get_client_arf_to_html_with_option_show_failed_rules() 0 3 1
A test_get_questions_not_selected_and_show_failed_rules() 0 7 1
A get_client_arf_to_html_with_option_show_not_selected_rules() 0 4 1
A test_prepare_tree_and_save_in_defined_destination() 0 7 1
A test_if_not_installed_inquirer_with_option_show_not_selected_rules_and_show_failed_rules() 0 11 2
A test_get_questions_not_selected() 0 6 1
1
import pytest
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
introduced by
import missing from __future__ import absolute_import
Loading history...
2
import tempfile
0 ignored issues
show
introduced by
standard import "import tempfile" should be placed before "import pytest"
Loading history...
3
import os
0 ignored issues
show
introduced by
standard import "import os" should be placed before "import pytest"
Loading history...
4
import uuid
0 ignored issues
show
introduced by
standard import "import uuid" should be placed before "import pytest"
Loading history...
5
import mock
6
import sys
0 ignored issues
show
introduced by
standard import "import sys" should be placed before "import pytest"
Loading history...
7
8
from oval_graph.arf_to_html import ArfToHtml
9
import tests.any_test_help
10
11
12
def get_client_arf_to_html(src, rule):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
13
    return ArfToHtml(["--display", tests.any_test_help.get_src(src), rule])
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
14
15
16
def get_client_arf_to_html_with_define_dest(src, rule):
0 ignored issues
show
Coding Style Naming introduced by
Function name "get_client_arf_to_html_with_define_dest" 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...
17
    return ArfToHtml(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
18
        ["--output", tests.any_test_help.get_src(
19
            os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))),
20
         tests.any_test_help.get_src(src),
21
         rule])
22
23
24
def get_client_arf_to_html_with_option_show_failed_rules(src, rule):
0 ignored issues
show
Coding Style Naming introduced by
Function name "get_client_arf_to_html_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...
25
    return ArfToHtml(["--show-failed-rules",
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
26
                      tests.any_test_help.get_src(src), rule])
27
28
29
def get_client_arf_to_html_with_option_show_not_selected_rules(src, rule):
0 ignored issues
show
Coding Style Naming introduced by
Function name "get_client_arf_to_html_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...
30
    return ArfToHtml(["--show-not-selected-rules",
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
31
                      tests.any_test_help.get_src(src),
32
                      rule])
33
34
35
def get_client_arf_to_html_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 (85/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 "get_client_arf_to_html_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...
36
        src,
37
        rule):
38
    return ArfToHtml(["--show-not-selected-rules",
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
39
                      "--show-failed-rules",
40
                      tests.any_test_help.get_src(src),
41
                      rule])
42
43
44
def try_expection_for_prepare_graph(src, rule, err):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
45
    client = get_client_arf_to_html(src, rule)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
46
    rules = {'rules': [rule]}
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
47
    with pytest.raises(Exception, match=err):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
48
        assert client.prepare_data(rules)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
49
50
51
def test_prepare_graph_with_non_existent_rule():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_prepare_graph_with_non_existent_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...
52
    src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
53
    rule = 'non-existent_rule'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
54
    try_expection_for_prepare_graph(src, rule, '404')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
55
56
57
def test_prepare_graph_with_not_selected_rule():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_prepare_graph_with_not_selected_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...
58
    src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
59
    rule = 'xccdf_org.ssgproject.content_rule_package_nis_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
60
    try_expection_for_prepare_graph(src, rule, 'not selected')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
61
62
63
@pytest.mark.usefixtures("remove_generated_reports_in_root")
64
def test_prepare_tree():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
65
    src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
66
    rule = '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...
67
    client = get_client_arf_to_html(src, rule)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
68
    rules = {'rules': [rule]}
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
69
    results_src = client.prepare_data(rules)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
70
    tests.any_test_help.compare_results_html(results_src[0])
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
71
    client.kill_web_browsers()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
72
73
74
def test_prepare_tree_and_save_in_defined_destination():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_prepare_tree_and_save_in_defined_destination" 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...
75
    src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
76
    rule = '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...
77
    client = get_client_arf_to_html_with_define_dest(src, rule)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
78
    rules = {'rules': [rule]}
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
79
    results_src = client.prepare_data(rules)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
80
    tests.any_test_help.compare_results_html(results_src[0])
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
81
82
83
def test_get_questions_not_selected(capsys):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
84
    src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
85
    regex = r'_package_\w+_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
86
    client = get_client_arf_to_html_with_option_show_not_selected_rules(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
87
        src, regex)
88
    tests.any_test_help.get_questions_not_selected(capsys, client)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
89
90
91
def test_get_questions_not_selected_and_show_failed_rules(capsys):
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_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...
92
    src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
93
    regex = r'_package_\w+_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
94
    client = get_client_arf_to_html_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 (94/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 4 tabs, expected 1
Loading history...
95
        src, regex)
96
    tests.any_test_help.get_questions_not_selected_and_show_failed_rules(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
97
        capsys, client)
98
99
100
def test_get_questions_with_option_show_failed_rules():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_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...
101
    src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
102
    regex = r'_package_\w+_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
103
    client = get_client_arf_to_html_with_option_show_failed_rules(src, regex)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
104
    tests.any_test_help.get_questions_with_option_show_failed_rules(client)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
105
106
107
def test_if_not_installed_inquirer_with_option_show_failed_rules(capsys):
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_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...
108
    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...
109
        src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
110
        regex = r'_package_\w+_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
111
        client = get_client_arf_to_html_with_option_show_failed_rules(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
112
            src, regex)
113
        client.isatty = True
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
114
        tests.any_test_help.if_not_installed_inquirer_with_option_show_failed_rules(
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (84/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...
115
            capsys, client)
116
117
118
def test_if_not_installed_inquirer_with_option_show_not_selected_rules(capsys):
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_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...
119
    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...
120
        src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
121
        regex = r'_package_\w+_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
122
        client = get_client_arf_to_html_with_option_show_not_selected_rules(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
123
            src, regex)
124
        client.isatty = True
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
125
        tests.any_test_help.if_not_installed_inquirer_with_option_show_not_selected_rules(
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (90/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...
126
            capsys, client)
127
128
129
def test_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 (93/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 "test_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...
130
        capsys):
131
    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...
132
        src = 'test_data/ssg-fedora-ds-arf.xml'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
133
        regex = r'_package_\w+_removed'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
134
        client = get_client_arf_to_html_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 (98/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...
135
            src, regex)
136
        client.isatty = True
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
137
        (tests.any_test_help.
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
138
         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 (93/80).

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

Loading history...
139
             capsys, client))
140