8000 changed plot_option to world_readable and updated the tests · henrypan/python-api@ecb7de8 · GitHub
[go: up one dir, main page]

Skip to content

Commit ecb7de8

Browse files
committed
changed plot_option to world_readable and updated the tests
1 parent 9cdf568 commit ecb7de8

File tree

4 files changed

+78
-162
lines changed

4 files changed

+78
-162
lines changed

plotly/plotly/plotly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
DEFAULT_PLOT_OPTIONS = {
3838
'filename': "plot from API",
3939
'fileopt': "new",
40-
'world_readable': False,
40+
'world_readable': True,
4141
'auto_open': True,
4242
'validate': True
4343
}

plotly/session.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
'plotly_streaming_domain': six.string_types,
3131
'plotly_api_domain': six.string_types,
3232
'plotly_ssl_verification': bool,
33-
'plot_options': {'world_readable': bool}
33+
'plotly_proxy_authorization': bool,
34+
'world_readable': bool
3435
}
3536

3637
PLOT_OPTIONS = {
@@ -57,15 +58,9 @@ def sign_in(username, api_key, **kwargs):
5758
:param (str|optional) plotly_domain:
5859
:param (str|optional) plotly_streaming_domain:
5960
:param (str|optional) plotly_api_domain:
60-
<<<<<<< HEAD
61-
:param (str|optional) plotly_ssl_verification:
62-
:param (dict|optional) plot_option:
63-
||||||| merged common ancestors
64-
:param (str|optional) plotly_ssl_verification:
65-
=======
6661
:param (bool|optional) plotly_ssl_verification:
6762
:param (bool|optional) plotly_proxy_authorization:
68-
>>>>>>> afe8b56bb06320a90ce3a404264bc8b3060b87da
63+
:param (bool|optional) world_readable:
6964
7065
"""
7166
# TODO: verify these _credentials with plotly
Lines changed: 33 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
<<<<<<< HEAD
2-
<<<<<<< HEAD
3-
from unittest import TestCase
4-
51
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
142
from plotly.tests.utils import PlotlyTestCase
15-
>>>>>>> 6f2eb8a4d210809121fe7536e2150ff8f30b8168
163

174

185
class FileToolsTest(PlotlyTestCase):
@@ -21,47 +8,52 @@ def test_set_config_file_all_entries(self):
218

229
# Check set_config and get_config return the same values
2310

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)
3219
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()
3827

3928
def test_set_config_file_two_entries(self):
4029

4130
# Check set_config and get_config given only two entries return the
4231
# same values
4332

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)
4636
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()
4940

5041
def test_session_plot_option(self):
5142

5243
# Check if the session_plot_option and config_plot_optin return the
5344
# same value
5445

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()
5951

60-
def test_set_config_file_plot_option(self):
52+
def test_set_config_file_world_readable(self):
6153

62-
# Return TypeError when plot_option type is not a dict
54+
# Return TypeError when world_readable type is not a dict
6355

64-
kwargs = {'plot_option': False}
56+
kwargs = {'world_readable': 'True'}
6557
self.assertRaises(TypeError, tools.set_config_file, **kwargs)
6658

6759
def test_reset_config_file(self):
@@ -78,7 +70,8 @@ def test_get_credentials_file(self):
7870
# Check get_credentials returns all the keys
7971

8072
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']
8275
self.assertTrue(all(x in original_creds for x in expected))
8376

8477
def test_reset_credentials_file(self):
@@ -87,79 +80,6 @@ def test_reset_credentials_file(self):
8780

8881
tools.reset_credentials_file()
8982
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']
9185
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

Comments
 (0)
0