Passed
Push — codeStyle ( 8912bb...a542d4 )
by Jan
02:08
created

any_test_help.any_get_test_data_json()   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
import graph.oval_graph
2
import os
3
import py
4
import json
5
6
def any_test_treeEvaluation(tree, expect):
7
    assert tree.evaluate_tree() == expect
8
9
def any_test_parsing_and_evaluate_scan_rule(src, rule_id, result):
10
    _dir = os.path.dirname(os.path.realpath(__file__))
11
    FIXTURE_DIR = py.path.local(_dir) / src
12
13
    oval_tree = graph.oval_graph.build_nodes_form_xml(
14
        str(FIXTURE_DIR), rule_id)
15
    any_test_treeEvaluation(oval_tree, result)
16
17
def any_get_test_data_json(src):
18
    _dir = os.path.dirname(os.path.realpath(__file__))
19
    FIXTURE_DIR = py.path.local(_dir) / src
20
21
    with open(str(FIXTURE_DIR), 'r') as f:
22
        data = json.load(f)
23
    return data
24
25
def any_test_create_node_dict_for_sigmaJs(Tree, out):
26
27
    assert Tree._create_node(0, 0) == out
28
29
def get_simple_tree():
30
    return graph.oval_graph.OvalNode(1, 'operator', 'and', [
31
        graph.oval_graph.OvalNode(2, 'value', "true"),
32
        graph.oval_graph.OvalNode(3, 'value', "false"),
33
        graph.oval_graph.OvalNode(4, 'operator', 'or', [
34
            graph.oval_graph.OvalNode(5, 'value', "false"),
35
            graph.oval_graph.OvalNode(6, 'value', "true")
36
        ]
37
        )
38
    ]
39
    )
40
41
42
def get_dict_of_simple_tree():
43
    return get_simple_tree().save_tree_to_dict()
44