forked from plotly/plotly.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_data.py
More file actions
87 lines (56 loc) · 1.72 KB
/
test_data.py
File metadata and controls
87 lines (56 loc) · 1.72 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
"""
test_data:
==========
A module intended for use with Nose.
"""
from nose.tools import raises
from ...graph_objs.graph_objs import *
from ...exceptions import (PlotlyError,
PlotlyDictKeyError,
PlotlyDictValueError,
PlotlyDataTypeError, PlotlyListEntryError)
def setup():
import warnings
warnings.filterwarnings('ignore')
def test_trivial():
assert Data() == list()
@raises(PlotlyError)
def test_weird_instantiation(): # Python allows this...
print Data({})
def test_default_scatter():
assert Data([{}]) == list([{'type': 'scatter'}])
def test_dict_instantiation():
Data([{'type': 'scatter'}])
@raises(PlotlyDictKeyError)
def test_dict_instantiation_key_error():
print Data([{'not-a-key': 'anything'}])
@raises(PlotlyDictValueError)
def test_dict_instantiation_key_error():
print Data([{'marker': 'not-a-dict'}])
@raises(PlotlyDataTypeError)
def test_dict_instantiation_type_error():
Data([{'type': 'invalid_type'}])
@raises(PlotlyListEntryError)
def test_dict_instantiation_graph_obj_error_0():
Data([Data()])
@raises(PlotlyListEntryError)
def test_dict_instantiation_graph_obj_error_1():
Data([Figure()])
@raises(PlotlyListEntryError)
def test_dict_instantiation_graph_obj_error_2():
Data([Annotations()])
@raises(PlotlyListEntryError)
def test_dict_instantiation_graph_obj_error_3():
Data([Layout()])
def test_validate():
data = Data()
data.validate()
data += [{'type': 'scatter'}]
data.validate()
data += [{},{},{}]
data.validate()
@raises(PlotlyDictKeyError)
def test_validate_error():
data = Data()
data.append({'not-a-key': 'anything'})
data.validate()