9
9
10
10
from unittest import TestCase , skipIf
11
11
12
- from nose .plugins .attrib import attr
13
- from nose .tools import raises
14
-
15
12
import six
13
+ from nose .plugins .attrib import attr
16
14
17
15
from plotly import exceptions
18
- from plotly .graph_objs import graph_objs
19
16
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
23
18
24
19
25
20
def is_trivial (obj ):
@@ -41,75 +36,59 @@ def is_trivial(obj):
41
36
return False
42
37
43
38
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
+
113
92
class TestBytesVStrings (TestCase ):
114
93
115
94
@skipIf (not six .PY3 , 'Decoding and missing escapes only seen in PY3' )
@@ -118,6 +97,4 @@ def test_proper_escaping(self):
118
97
ak = '786r5mecv0'
119
98
url = "https://plot.ly/~PlotlyImageTest/91/"
120
99
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