1
- < << << << HEAD
2
- < << << << HEAD
3
- from unittest import TestCase
4
-
5
1
from plotly import tools , session
6
- | | | | | | | merged common ancestors
7
- from unittest import TestCase
8
-
9
- from plotly import tools
10
- from plotly import session
11
- == == == =
12
- from plotly import tools
13
- from plotly import session
14
2
from plotly .tests .utils import PlotlyTestCase
15
- > >> >> >> 6 f2eb8a4d210809121fe7536e2150ff8f30b8168
16
3
17
4
18
5
class FileToolsTest (PlotlyTestCase ):
@@ -21,47 +8,52 @@ def test_set_config_file_all_entries(self):
21
8
22
9
# Check set_config and get_config return the same values
23
10
24
- pd , ps , pa = 'this' , 'thing' , 'that'
25
- psv = False
26
- po = { 'world_readable' : False }
27
- tools . set_config_file ( plotly_domain = pd ,
28
- plotly_streaming_domain = ps ,
29
- plotly_api_domain = pa ,
30
- plotly_ssl_verification = psv ,
31
- plot_options = po )
11
+ domain , streaming_domain , api = 'this' , 'thing' , 'that'
<
628C
code>12 + ssl_verify , proxy_auth , readable = True , True , True
13
+ tools . set_config_file ( plotly_domain = domain ,
14
+ plotly_streaming_domain = streaming_domain ,
15
+ plotly_api_domain = api ,
16
+ plotly_ssl_verification = ssl_verify ,
17
+ plotly_proxy_authorization = proxy_auth ,
18
+ world_readable = readable )
32
19
config = tools .get_config_file ()
33
- self .assertEqual (config ['plotly_domain' ], pd )
34
- self .assertEqual (config ['plotly_streaming_domain' ], ps )
35
- self .assertEqual (config ['plotly_api_domain' ], pa )
36
- self .assertEqual (config ['plotly_ssl_verification' ], psv )
37
- self .assertEqual (config ['plot_options' ], po )
20
+ self .assertEqual (config ['plotly_domain' ], domain )
21
+ self .assertEqual (config ['plotly_streaming_domain' ], streaming_domain )
22
+ self .assertEqual (config ['plotly_api_domain' ], api )
23
+ self .assertEqual (config ['plotly_ssl_verification' ], ssl_verify )
24
+ self .assertEqual (config ['plotly_proxy_authorization' ], proxy_auth )
25
+ self .assertEqual (config ['world_readable' ], readable )
26
+ tools .reset_config_file ()
38
27
39
28
def test_set_config_file_two_entries (self ):
40
29
41
30
# Check set_config and get_config given only two entries return the
42
31
# same values
43
32
44
- pd , ps = 'this' , 'thing'
45
- tools .set_config_file (plotly_domain = pd , plotly_streaming_domain = ps )
33
+ domain , streaming_domain = 'this' , 'thing'
34
+ tools .set_config_file (plotly_domain = domain ,
35
+ plotly_streaming_domain = streaming_domain )
46
36
config = tools .get_config_file ()
47
- self .assertEqual (config ['plotly_domain' ], pd )
48
- self .assertEqual (config ['plotly_streaming_domain' ], ps )
37
+ self .assertEqual (config ['plotly_domain' ], domain )
38
+ self .assertEqual (config ['plotly_streaming_domain' ], streaming_domain )
39
+ tools .reset_config_file ()
49
40
50
41
def test_session_plot_option (self ):
51
42
52
43
# Check if the session_plot_option and config_plot_optin return the
53
44
# same value
54
45
55
- po = {'world_readable' : True }
56
- tools .set_config_file (plot_options = po )
57
- session_po = session .get_session_plot_options ()
58
- self .assertEqual (session_po ['world_readable' ], po ['world_readable' ])
46
+ readable = False
47
+ tools .set_config_file (world_readable = readable )
48
+ session_plot_option = session .get_session_plot_options ()
49
+ self .assertEqual (session_plot_option ['world_readable' ], readable )
50
+ tools .reset_config_file ()
59
51
60
- def test_set_config_file_plot_option (self ):
52
+ def test_set_config_file_world_readable (self ):
61
53
62
- # Return TypeError when plot_option type is not a dict
54
+ # Return TypeError when world_readable type is not a dict
63
55
64
- kwargs = {'plot_option ' : False }
56
+ kwargs = {'world_readable ' : 'True' }
65
57
self .assertRaises (TypeError , tools .set_config_file , ** kwargs )
66
58
67
59
def test_reset_config_file (self ):
@@ -78,7 +70,8 @@ def test_get_credentials_file(self):
78
70
# Check get_credentials returns all the keys
79
71
80
72
original_creds = tools .get_credentials_file ()
81
- expected = ['username' , 'stream_ids' , 'api_key' ]
73
+ expected = ['username' , 'stream_ids' , 'api_key' , 'proxy_username' ,
74
+ 'proxy_password' ]
82
75
self .assertTrue (all (x in original_creds for x in expected ))
83
76
84
77
def test_reset_credentials_file (self ):
@@ -87,79 +80,6 @@ def test_reset_credentials_file(self):
87
80
88
81
tools .reset_credentials_file ()
89
82
reset_creds = tools .get_credentials_file ()
90
- expected = ['username' , 'stream_ids' , 'api_key' ]
83
+ expected = ['username' , 'stream_ids' , 'api_key' , 'proxy_username' ,
84
+ 'proxy_password' ]
91
85
self .assertTrue (all (x in reset_creds for x in expected ))
92
- | | | | | | | merged common ancestors
93
- import plotly .tools as tls
94
-
95
-
96
- def test_reset_config_file ():
97
- tls .reset_config_file ()
98
- config = tls .get_config_file ()
99
- assert config ['plotly_domain' ] == 'https://plot.ly'
100
- assert config ['plotly_streaming_domain' ] == 'stream.plot.ly'
101
-
102
-
103
- def test_set_config_file ():
104
- pd , ps = 'this' , 'thing'
105
- tls .set_config_file (plotly_domain = pd , plotly_streaming_domain = ps )
106
- config = tls .get_config_file ()
107
- assert config ['plotly_domain' ] == pd
108
- assert config ['plotly_streaming_domain' ] == ps
109
- tls .reset_config_file () # else every would hate me :)
110
-
111
-
112
- def test_credentials_tools ():
113
- original_creds = tls .get_credentials_file ()
114
- expected = ['username' , 'stream_ids' , 'api_key' ]
115
- assert all (x in original_creds for x in expected )
116
- # now, if that worked, we can try this!
117
- tls .reset_credentials_file ()
118
- reset_creds = tls .get_credentials_file ()
119
- tls .set_credentials_file (** original_creds )
120
- assert all (x in reset_creds for x in expected )
121
- creds = tls .get_credentials_file ()
122
- assert all (x in creds for x in expected )
123
- assert original_creds == creds
124
- == == == =
125
- from __future__ import absolute_import
126
-
127
- import plotly .tools as tls
128
-
129
-
130
- def test_reset_config_file ():
131
- tls .reset_config_file ()
132
- config = tls .get_config_file ()
133
- assert config ['plotly_domain' ] == 'https://plot.ly'
134
- assert config ['plotly_streaming_domain' ] == 'stream.plot.ly'
135
-
136
-
137
- def test_set_config_file ():
138
- pd , ps = 'this' , 'thing'
139
- ssl_verify , proxy_auth = True , True
140
- tls .set_config_file (plotly_domain = pd , plotly_streaming_domain = ps ,
141
- plotly_ssl_verification = ssl_verify ,
142
- plotly_proxy_authorization = proxy_auth )
143
- config = tls .get_config_file ()
144
- assert config ['plotly_domain' ] == pd
145
- assert config ['plotly_streaming_domain' ] == ps
146
- assert config ['plotly_ssl_verification' ] == ssl_verify
147
- assert config ['plotly_proxy_authorization' ] == proxy_auth
148
- tls .reset_config_file () # else every would hate me :)
149
-
150
-
151
- def test_credentials_tools ():
152
- original_creds = tls .get_credentials_file ()
153
- expected = ['username' , 'stream_ids' , 'api_key' , 'proxy_username' ,
154
- 'proxy_password' ]
155
- assert all (x in original_creds for x in expected )
156
-
157
- # now, if that worked, we can try this!
158
- tls .reset_credentials_file ()
159
- reset_creds = tls .get_credentials_file ()
160
- tls .set_credentials_file (** original_creds )
161
- assert all (x in reset_creds for x in expected )
162
- creds = tls .get_credentials_file ()
163
- assert all (x in creds for x in expected )
164
- assert original_creds == creds
165
- > >> >> >> afe8b56bb06320a90ce3a404264bc8b3060b87da
0 commit comments