forked from plotly/plotly.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_graph_references.py
More file actions
55 lines (47 loc) · 1.65 KB
/
test_graph_references.py
File metadata and controls
55 lines (47 loc) · 1.65 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
import json
with open('graph_objs_meta.json') as f:
INFO = json.load(f)
types = ['data', 'plot_info', 'style', 'object']
attr_keys = ['required',
'description',
'examples', # todo: do we want this?
'type',
'val_types',
'streamable',
'code', # todo: do we want this?
'default'] # todo: do we want this?
def test_type_exists():
print "\n\ntesting if keys have 'type'\n"
checks = True
for obj_key, obj in INFO.items():
if obj_key != 'trace':
for attr_key, attr_dict in obj.items():
if 'type' not in attr_dict:
checks = False
print obj_key, attr_key
if not checks:
raise Exception
def test_for_invalid_attr_keys():
print "\n\ntesting if attr keys are valid\n"
checks = True
for obj_key, obj in INFO.items():
if obj_key != 'trace':
for attr_key, attr_dict in obj.items():
for attr in attr_dict:
if attr not in attr_keys:
print obj_key, attr_key, attr
checks = False
if not checks:
raise Exception
def test_type_value():
print "\n\ntesting if 'type' values are valid\n"
checks = True
for obj_key, obj in INFO.items():
if obj_key != 'trace':
for attr_key, attr_dict in obj.items():
if 'type' in attr_dict:
if attr_dict['type'] not in types:
print obj_key, attr_key, attr_dict['type']
checks = False
if not checks:
raise Exception