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

test_json_to_html   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 46
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A tests.test_json_to_html.test_prepare_tree() 0 8 1
A tests.test_json_to_html.get_client_json_to_html() 0 2 1
A tests.test_json_to_html.test_prepare_tree_and_save_in_defined_destination() 0 6 1
A tests.test_json_to_html.test_prepare_graph_with_not_valid_file() 0 4 1
A tests.test_json_to_html.test_prepare_graph_with_bat_data() 0 4 1
A tests.test_json_to_html.test_prepare_graph_with_not_exist_rule() 0 4 1
A tests.test_json_to_html.get_client_json_to_html_with_define_dest() 0 6 1
A tests.test_json_to_html.try_expection_for_prepare_graph() 0 5 2
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
6
from oval_graph.json_to_html import JsonToHtml
7
import tests.any_test_help
8
9
10
def get_client_json_to_html(src, rule):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
11
    return JsonToHtml(["--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...
12
13
14
def get_client_json_to_html_with_define_dest(src, rule):
0 ignored issues
show
Coding Style Naming introduced by
Function name "get_client_json_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...
15
    return JsonToHtml(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
16
        ["--output", tests.any_test_help.get_src(
17
            os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))),
18
         tests.any_test_help.get_src(src),
19
         rule,
20
         ])
21
22
23
def try_expection_for_prepare_graph(src, rule, err):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
24
    rules = {'rules': [rule]}
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
25
    with pytest.raises(Exception, match=err):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
26
        client = get_client_json_to_html(src, rule)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
27
        assert client.prepare_data(rules)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
28
29
30
def test_prepare_graph_with_not_valid_file():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_prepare_graph_with_not_valid_file" 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...
31
    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...
32
    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...
33
    try_expection_for_prepare_graph(src, rule, 'is not valid json')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
34
35
36
def test_prepare_graph_with_not_exist_rule():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_prepare_graph_with_not_exist_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...
37
    src = 'test_data/referenc_html_report.html'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
38
    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...
39
    try_expection_for_prepare_graph(src, rule, 'No such file or directory:')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
40
41
42
def test_prepare_graph_with_bat_data():
0 ignored issues
show
Coding Style Naming introduced by
Function name "test_prepare_graph_with_bat_data" 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...
43
    src = 'test_data/bad_result_data_json.json'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
44
    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...
45
    try_expection_for_prepare_graph(src, rule, 'valid for OVAL tree')
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
46
47
48
@pytest.mark.usefixtures("remove_generated_reports_in_root")
49
def test_prepare_tree():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
50
    src = 'test_data/referenc_result_data_json.json'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
51
    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...
52
    client = get_client_json_to_html(src, rule)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
53
    results_src = client.prepare_data({'rules': client.search_rules_id()})
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
54
    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...
55
    client.kill_web_browsers()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
56
57
58
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...
59
    src = 'test_data/referenc_result_data_json.json'
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
60
    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...
61
    client = get_client_json_to_html_with_define_dest(src, rule)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
62
    results_src = client.prepare_data({'rules': client.search_rules_id()})
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
63
    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...
64