1
+ """
2
+ test_plot_mpl:
3
+ ==============
4
+
5
+ A module intended for use with Nose.
6
+
7
+ """
8
+ from ... plotly import plotly as py
9
+ from ... import exceptions
10
+ from nose .tools import raises
11
+ import matplotlib .pyplot as plt
12
+
13
+ py .sign_in ('test-runner' , '9h29fe3l0x' )
14
+
15
+ @raises (exceptions .PlotlyError )
16
+ def test_update_type_error ():
17
+ fig , ax = plt .subplots ()
18
+ ax .plot ([1 , 2 , 3 ])
19
+ update = []
20
+ py .plot_mpl (fig , update = update , filename = "nosetests" , auto_open = False )
21
+
22
+
23
+ @raises (exceptions .PlotlyError )
24
+ def test_update_validation_error ():
25
+ fig , ax = plt .subplots ()
26
+ ax .plot ([1 , 2 , 3 ])
27
+ update = {'invalid' : 'anything' }
28
+ py .plot_mpl (fig , update = update , filename = "nosetests" , auto_open = False )
29
+
30
+
31
+ def test_update ():
32
+ fig , ax = plt .subplots ()
33
+ ax .plot ([1 , 2 , 3 ])
34
+ title = 'new title'
35
+ update = {'layout' : {'title' : title }}
36
+ url = py .plot_mpl (fig , update = update , filename = "nosetests" , auto_open = False )
37
+ un = url .replace ("https://plot.ly/~" , "" ).split ('/' )[0 ]
38
+ fid = url .replace ("https://plot.ly/~" , "" ).split ('/' )[1 ]
39
+ pfig = py .get_figure (un , fid )
40
+ assert pfig ['layout' ]['title' ] == title
0 commit comments