forked from plotly/plotly.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_plot.py
More file actions
68 lines (48 loc) · 1.42 KB
/
test_plot.py
File metadata and controls
68 lines (48 loc) · 1.42 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
"""
test_plot:
==========
A module intended for use with Nose.
"""
from __future__ import absolute_import
from unittest import TestCase
from nose.tools import raises
from plotly.exceptions import PlotlyError, PlotlyEmptyDataError
from plotly.plotly import plotly as py
# username for tests: 'PlotlyImageTest'
# api_key for account: '786r5mecv0'
def setUp():
py.sign_in('PlotlyImageTest', '786r5mecv0',
plotly_domain='https://plot.ly')
def test_plot_valid():
fig = {
'data': [
{
'x': [1, 2, 3],
'y': [2, 1, 2]
}
]
}
py.plot(fig, auto_open=False, filename='plot_valid')
@raises(PlotlyError)
def test_plot_invalid():
fig = {
'data': [
{
'x': [1, 2, 3],
'y': [2, 1, 2],
'z': [3, 4, 1]
}
]
}
py.plot(fig, auto_open=False, filename='plot_invalid')
@raises(TypeError)
def test_plot_invalid_args_1():
py.plot(x=[1, 2, 3], y=[2, 1, 2], auto_open=False, filename='plot_invalid')
@raises(PlotlyError)
def test_plot_invalid_args_2():
py.plot([1, 2, 3], [2, 1, 2], auto_open=False, filename='plot_invalid')
class TestPlot(TestCase):
def test_plot_empty_data(self):
py.sign_in('PlotlyImageTest', '786r5mecv0')
self.assertRaises(PlotlyEmptyDataError, py.plot, [],
filename='plot_invalid')