Skip to content

Commit 74d3a30

Browse files
committed
🔧 Cleanup test_get_figure.py.
1 parent 9a7a8f1 commit 74d3a30

File tree

1 file changed

+56
-79
lines changed

1 file changed

+56
-79
lines changed

plotly/tests/test_core/test_get_figure/test_get_figure.py

+56-79
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99

1010
from unittest import TestCase, skipIf
1111

12-
from nose.plugins.attrib import attr
13-
from nose.tools import raises
14-
1512
import six
13+
from nose.plugins.attrib import attr
1614

1715
from plotly import exceptions
18-
from plotly.graph_objs import graph_objs
1916
from plotly.plotly import plotly as py
20-
21-
# username for tests: 'plotlyimagetest'
22-
# api_key for account: '786r5mecv0'
17+
from plotly.tests.utils import PlotlyTestCase
2318

2419

2520
def is_trivial(obj):
@@ -41,75 +36,59 @@ def is_trivial(obj):
4136
return False
4237

4338

44-
@attr('slow')
45-
def test_get_figure():
46-
un = 'PlotlyImageTest'
47-
ak = '786r5mecv0'
48-
file_id = 2
49-
py.sign_in(un, ak)
50-
print("getting: https://plot.ly/~{0}/{1}/".format(un, file_id))
51-
print("###########################################\n\n")
52-
fig = py.get_figure('PlotlyImageTest', str(file_id))
53-
54-
55-
@attr('slow')
56-
def test_get_figure_with_url():
57-
un = 'PlotlyImageTest'
58-
ak = '786r5mecv0'
59-
url = "https://plot.ly/~PlotlyImageTest/2/"
60-
py.sign_in(un, ak)
61-
print("getting: https://plot.ly/~PlotlyImageTest/2/")
62-
print("###########################################\n\n")
63-
fig = py.get_figure(url)
64-
65-
66-
@raises(exceptions.PlotlyError)
67-
def test_get_figure_invalid_1():
68-
un = 'PlotlyImageTest'
69-
ak = '786r5mecv0'
70-
url = "https://plot.ly/~PlotlyImageTest/a/"
71-
py.sign_in(un, ak)
72-
print("not getting: https://plot.ly/~PlotlyImageTest/a/")
73-
print("###########################################\n\n")
74-
fig = py.get_figure(url)
75-
76-
77-
@attr('slow')
78-
@raises(exceptions.PlotlyError)
79-
def test_get_figure_invalid_2():
80-
un = 'PlotlyImageTest'
81-
ak = '786r5mecv0'
82-
url = "https://plot.ly/~PlotlyImageTest/-1/"
83-
py.sign_in(un, ak)
84-
print("not getting: https://plot.ly/~PlotlyImageTest/-1/")
85-
print("###########################################\n\n")
86-
fig = py.get_figure(url)
87-
88-
89-
@attr('slow')
90-
@raises(exceptions.PlotlyError)
91-
def test_get_figure_does_not_exist():
92-
un = 'PlotlyImageTest'
93-
ak = '786r5mecv0'
94-
url = "https://plot.ly/~PlotlyImageTest/1000000000/"
95-
py.sign_in(un, ak)
96-
print("not getting: https://plot.ly/~PlotlyImageTest/1000000000/")
97-
print("###########################################\n\n")
98-
fig = py.get_figure(url)
99-
100-
101-
@attr('slow')
102-
def test_get_figure_raw():
103-
un = 'PlotlyImageTest'
104-
ak = '786r5mecv0'
105-
file_id = 2
106-
py.sign_in(un, ak)
107-
print("getting: https://plot.ly/~{0}/{1}/".format(un, file_id))
108-
print("###########################################\n\n")
109-
fig = py.get_figure('PlotlyImageTest', str(file_id), raw=True)
110-
111-
112-
@attr('slow')
39+
class GetFigureTest(PlotlyTestCase):
40+
41+
@attr('slow')
42+
def test_get_figure(self):
43+
un = 'PlotlyImageTest'
44+
ak = '786r5mecv0'
45+
file_id = 2
46+
py.sign_in(un, ak)
47+
py.get_figure('PlotlyImageTest', str(file_id))
48+
49+
@attr('slow')
50+
def test_get_figure_with_url(self):
51+
un = 'PlotlyImageTest'
52+
ak = '786r5mecv0'
53+
url = "https://plot.ly/~PlotlyImageTest/2/"
54+
py.sign_in(un, ak)
55+
py.get_figure(url)
56+
57+
def test_get_figure_invalid_1(self):
58+
un = 'PlotlyImageTest'
59+
ak = '786r5mecv0'
60+
url = "https://plot.ly/~PlotlyImageTest/a/"
61+
py.sign_in(un, ak)
62+
with self.assertRaises(exceptions.PlotlyError):
63+
py.get_figure(url)
64+
65+
@attr('slow')
66+
def test_get_figure_invalid_2(self):
67+
un = 'PlotlyImageTest'
68+
ak = '786r5mecv0'
69+
url = "https://plot.ly/~PlotlyImageTest/-1/"
70+
py.sign_in(un, ak)
71+
with self.assertRaises(exceptions.PlotlyError):
72+
py.get_figure(url)
73+
74+
@attr('slow')
75+
def test_get_figure_does_not_exist(self):
76+
un = 'PlotlyImageTest'
77+
ak = '786r5mecv0'
78+
url = "https://plot.ly/~PlotlyImageTest/1000000000/"
79+
py.sign_in(un, ak)
80+
with self.assertRaises(exceptions.PlotlyError):
81+
py.get_figure(url)
82+
83+
@attr('slow')
84+
def test_get_figure_raw(self):
85+
un = 'PlotlyImageTest'
86+
ak = '786r5mecv0'
87+
file_id = 2
88+
py.sign_in(un, ak)
89+
py.get_figure('PlotlyImageTest', str(file_id), raw=True)
90+
91+
11392
class TestBytesVStrings(TestCase):
11493

11594
@skipIf(not six.PY3, 'Decoding and missing escapes only seen in PY3')
@@ -118,6 +97,4 @@ def test_proper_escaping(self):
11897
ak = '786r5mecv0'
11998
url = "https://plot.ly/~PlotlyImageTest/91/"
12099
py.sign_in(un, ak)
121-
print("getting: https://plot.ly/~PlotlyImageTest/91/")
122-
print("###########################################\n\n")
123-
fig = py.get_figure(url)
100+
py.get_figure(url)

0 commit comments

Comments
 (0)