forked from plotly/plotly.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_plot_mpl.py
More file actions
40 lines (32 loc) · 1.08 KB
/
test_plot_mpl.py
File metadata and controls
40 lines (32 loc) · 1.08 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
"""
test_plot_mpl:
==============
A module intended for use with Nose.
"""
from ... plotly import plotly as py
from ... import exceptions
from nose.tools import raises
import matplotlib.pyplot as plt
py.sign_in('test-runner', '9h29fe3l0x')
@raises(exceptions.PlotlyError)
def test_update_type_error():
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
update = []
py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False)
@raises(exceptions.PlotlyError)
def test_update_validation_error():
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
update = {'invalid': 'anything'}
py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False)
def test_update():
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
title = 'new title'
update = {'layout': {'title': title}}
url = py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False)
un = url.replace("https://plot.ly/~", "").split('/')[0]
fid = url.replace("https://plot.ly/~", "").split('/')[1]
pfig = py.get_figure(un, fid)
assert pfig['layout']['title'] == title