forked from pombreda/graph_reference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_graph_references.py
More file actions
104 lines (94 loc) · 3.84 KB
/
test_graph_references.py
File metadata and controls
104 lines (94 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import json
# -------------------------------------------------------------------------------
#
# Each dictionary is represented with KEYS and VALS i.e. dict(KEY=VAL),
# to avoid confusion with graph objs key, keymeta, etc ...
#
# -------------------------------------------------------------------------------
# Only need to test one output file (they all have the same keys)
with open('./graph_objs/python/graph_objs_meta.json') as f:
META = json.load(f)
# -------------------------------------------------------------------------------
graph_obj_meta_KEYS = [
'name',
'obj_type',
'parent_keys',
'docstring',
'examples',
'links',
'keymeta'
]
graph_obj_key_KEYS = [
'key_type',
'required',
'val_types',
'description',
'examples',
'streamable'
]
graph_obj_key_type_VALS = [
'data',
'plot_info',
'style',
'object'
]
# -------------------------------------------------------------------------------
def test_meta_KEYS():
print "\n\ntesting if graph objs KEYS are in graph_objs_meta_KEYS\n"
checks = True
for graph_obj, graph_obj_meta in META.items():
for graph_obj_meta_KEY in graph_obj_meta.keys():
if graph_obj_meta_KEY not in graph_obj_meta_KEYS:
checks = False
print (
"You have a graph_obj_meta_KEY ('{}') not part "
"graph_obj_meta_KEYS at: {}"
).format(graph_obj_meta_KEY, graph_obj)
for graph_obj_meta_KEY in graph_obj_meta_KEYS:
if graph_obj_meta_KEY not in graph_obj_meta.keys():
checks = False
print (
"You are missing the '{}' graph_obj_meta_KEY at: {} "
).format(graph_obj_meta_KEY, graph_obj)
if not checks:
raise Exception
def test_key_KEYS():
print "\n\ntesting if graph objs key KEYS are graph_objs_key_KEYS\n"
checks = True
for graph_obj, graph_obj_meta in META.items():
if graph_obj != 'trace':
KEYMETA = graph_obj_meta['keymeta']
for graph_obj_key, graph_obj_keymeta in KEYMETA.items():
for graph_obj_key_KEY in graph_obj_keymeta.keys():
if graph_obj_key_KEY not in graph_obj_key_KEYS:
checks = False
print (
"You have a graph_obj_key_KEY ('{}')"
"not part graph_obj_key_KEYS at: {}.{}",
).format(graph_obj_key_KEY, graph_obj, graph_obj_key)
for graph_obj_key_KEY in graph_obj_key_KEYS[0:-2]:
if graph_obj_key_KEY not in graph_obj_keymeta.keys():
checks = False
print (
"You are missing the '{}' graph_obj_key_KEY "
"at: {}.{}"
).format(graph_obj_key_KEY, graph_obj, graph_obj_key),
if not checks:
raise Exception
def test_key_type_VALS():
print "\n\ntesting if graph objs key 'type' VALS are graph_objs_key_type_VALS\n"
checks = True
for graph_obj, graph_obj_meta in META.items():
if graph_obj != 'trace':
KEYMETA = graph_obj_meta['keymeta']
for graph_obj_key, graph_obj_keymeta in KEYMETA.items():
for graph_obj_key_KEY, graph_obj_key_VAL in graph_obj_keymeta.items():
if graph_obj_key_KEY == 'type':
if graph_obj_key_VAL not in graph_obj_key_type_VALS:
checks = False
print (
"You have a graph_obj_key_type_VAL ('{}') not part "
'graph_obj_key_type_VALS at: {}.{}.{}'
).format(graph_obj_key_VAL, graph_obj, graph_obj_key,'type')
if not checks:
raise Exception