Test Failed
Pull Request — master (#200)
by Jan
05:03
created

test_oval_evaluate.test_evaluation_of_oval_tree()   A

Complexity

Conditions 2

Size

Total Lines 37
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 33
nop 2
dl 0
loc 37
rs 9.0879
c 0
b 0
f 0
1
import json
2
import os
3
4
import pytest
5
6
from oval_graph.oval_tree.builder import Builder
7
8
9
def get_patch_to_data_source(data_source):
10
    directory = ''
11
    if data_source.startswith('AND'):
12
        directory = 'test_data_and'
13
    elif data_source.startswith('OR'):
14
        directory = 'test_data_or'
15
    elif data_source.startswith('XOR'):
16
        directory = 'test_data_xor'
17
    elif data_source.startswith('ONE'):
18
        directory = 'test_data_one'
19
    else:
20
        directory = 'test_data_NONE'
21
22
    top_patch = os.path.dirname(os.path.realpath(__file__))
23
    return os.path.join(top_patch, directory, data_source)
24
25
26
@pytest.mark.parametrize("data_source, expected_result", [
27
    ('ANDTreeTrue.json', "true"),
28
    ('ANDTreeFalse.json', 'false'),
29
    ('ANDTreeError.json', "error"),
30
    ('ANDTreeUnknown.json', "unknown"),
31
    ('ANDTreeNoteval.json', "noteval"),
32
    ("ANDTreeNotappl.json", 'notappl'),
33
34
    ('ONETreeTrue.json', "true"),
35
    ('ONETreeFalse.json', 'false'),
36
    ('ONETreeFalse1.json', 'false'),
37
    ('ONETreeError.json', "error"),
38
    ('ONETreeUnknown.json', "unknown"),
39
    ('ONETreeNoteval.json', "noteval"),
40
    ("ONETreeNotappl.json", 'notappl'),
41
42
    ('ORTreeTrue.json', "true"),
43
    ('ORTreeFalse.json', 'false'),
44
    ('ORTreeError.json', "error"),
45
    ('ORTreeUnknown.json', "unknown"),
46
    ('ORTreeNoteval.json', "noteval"),
47
    ("ORTreeNotappl.json", 'notappl'),
48
49
    ('XORTreeTrue.json', "true"),
50
    ('XORTreeFalse.json', 'false'),
51
    ('XORTreeError.json', "error"),
52
    ('XORTreeUnknown.json', "unknown"),
53
    ('XORTreeNoteval.json', "noteval"),
54
    ("XORTreeNotappl.json", 'notappl'),
55
])
56
def test_evaluation_of_oval_tree(data_source, expected_result):
57
    patch = get_patch_to_data_source(data_source)
58
    data = dict()
59
    with open(patch, "r") as file_:
60
        data = json.load(file_)
61
    oval_tree = Builder.dict_to_oval_tree(data)
62
    assert oval_tree.evaluate_tree() == expected_result
63
64
65
def test_bad_counts_evaluate():
66
    pass
67