8000 Config plot option by aneda · Pull Request #260 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

Config plot option #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changed plot_option to world_readable and updated the tests
  • Loading branch information
aneda committed Jul 17, 2015
commit ecb7de89cdf38269b2c3d8045905774ce6d3c504
2 changes: 1 addition & 1 deletion plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
DEFAULT_PLOT_OPTIONS = {
'filename': "plot from API",
'fileopt': "new",
'world_readable': False,
'world_readable': True,
'auto_open': True,
'validate': True
}
Expand Down
11 changes: 3 additions & 8 deletions plotly/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
'plotly_streaming_domain': six.string_types,
'plotly_api_domain': six.string_types,
'plotly_ssl_verification': bool,
'plot_options': {'world_readable': bool}
'plotly_proxy_authorization': bool,
'world_readable': bool
}

PLOT_OPTIONS = {
Expand All @@ -57,15 +58,9 @@ def sign_in(username, api_key, **kwargs):
:param (str|optional) plotly_domain:
:param (str|optional) plotly_streaming_domain:
:param (str|optional) plotly_api_domain:
<<<<<<< HEAD
:param (str|optional) plotly_ssl_verification:
:param (dict|optional) plot_option:
||||||| merged common ancestors
:param (str|optional) plotly_ssl_verification:
=======
:param (bool|optional) plotly_ssl_verification:
:param (bool|optional) plotly_proxy_authorization:
>>>>>>> afe8b56bb06320a90ce3a404264bc8b3060b87da
:param (bool|optional) world_readable:

"""
# TODO: verify these _credentials with plotly
Expand Down
146 changes: 33 additions & 113 deletions plotly/tests/test_core/test_tools/test_file_tools.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
<<<<<<< HEAD
<<<<<<< HEAD
from unittest import TestCase

from plotly import tools, session
||||||| merged common ancestors
from unittest import TestCase

from plotly import tools
from plotly import session
=======
from plotly import tools
from plotly import session
from plotly.tests.utils import PlotlyTestCase
>>>>>>> 6f2eb8a4d210809121fe7536e2150ff8f30b8168


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

# Check set_config and get_config return the same values

pd, ps, pa = 'this', 'thing', 'that'
psv = False
po = {'world_readable': False}
tools.set_config_file(plotly_domain=pd,
plotly_streaming_domain=ps,
plotly_api_domain=pa,
plotly_ssl_verification=psv,
plot_options=po)
domain, streaming_domain, api = 'this', 'thing', 'that'
ssl_verify, proxy_auth, readable = True, True, True
tools.set_config_file(plotly_domain=domain,
plotly_streaming_domain=streaming_domain,
plotly_api_domain=api,
plotly_ssl_verification=ssl_verify,
plotly_proxy_authorization=proxy_auth,
world_readable=readable)
config = tools.get_config_file()
self.assertEqual(config['plotly_domain'], pd)
self.assertEqual(config['plotly_streaming_domain'], ps)
self.assertEqual(config['plotly_api_domain'], pa)
self.assertEqual(config['plotly_ssl_verification'], psv)
self.assertEqual(config['plot_options'], po)
self.assertEqual(config['plotly_domain'], domain)
self.assertEqual(config['plotly_streaming_domain'], streaming_domain)
self.assertEqual(config['plotly_api_domain'], api)
self.assertEqual(config['plotly_ssl_verification'], ssl_verify)
self.assertEqual(config['plotly_proxy_authorization'], proxy_auth)
self.assertEqual(config['world_readable'], readable)
tools.reset_config_file()

def test_set_config_file_two_entries(self):

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

pd, ps = 'this', 'thing'
tools.set_config_file(plotly_domain=pd, plotly_streaming_domain=ps)
domain, streaming_domain = 'this', 'thing'
tools.set_config_file(plotly_domain=domain,
plotly_streaming_domain=streaming_domain)
config = tools.get_config_file()
self.assertEqual(config['plotly_domain'], pd)
self.assertEqual(config['plotly_streaming_domain'], ps)
self.assertEqual(config['plotly_domain'], domain)
self.assertEqual(config['plotly_streaming_domain'], streaming_domain)
tools.reset_config_file()

def test_session_plot_option(self):

# Check if the session_plot_option and config_plot_optin return the
# same value

po = {'world_readable': True}
tools.set_config_file(plot_options=po)
session_po = session.get_session_plot_options()
self.assertEqual(session_po['world_readable'], po['world_readable'])
readable = False
tools.set_config_file(world_readable=readable)
session_plot_option = session.get_session_plot_options()
self.assertEqual(session_plot_option['world_readable'], readable)
tools.reset_config_file()

def test_set_config_file_plot_option(self):
def test_set_config_file_world_readable(self):

# Return TypeError when plot_option type is not a dict
# Return TypeError when world_readable type is not a dict

kwargs = {'plot_option': False}
kwargs = {'world_readable': 'True'}
self.assertRaises(TypeError, tools.set_config_file, **kwargs)

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

original_creds = tools.get_credentials_file()
expected = ['username', 'stream_ids', 'api_key']
expected = ['username', 'stream_ids', 'api_key', 'proxy_username',
'proxy_password']
self.assertTrue(all(x in original_creds for x in expected))

def test_reset_credentials_file(self):
Expand All @@ -87,79 +80,6 @@ def test_reset_credentials_file(self):

tools.reset_credentials_file()
reset_creds = tools.get_credentials_file()
expected = ['username', 'stream_ids', 'api_key']
expected = ['username', 'stream_ids', 'api_key', 'proxy_username',
'proxy_password']
self.assertTrue(all(x in reset_creds for x in expected))
||||||| merged common ancestors
import plotly.tools as tls


def test_reset_config_file():
tls.reset_config_file()
config = tls.get_config_file()
assert config['plotly_domain'] == 'https://plot.ly'
assert config['plotly_streaming_domain'] == 'stream.plot.ly'


def test_set_config_file():
pd, ps = 'this', 'thing'
tls.set_config_file(plotly_domain=pd, plotly_streaming_domain=ps)
config = tls.get_config_file()
assert config['plotly_domain'] == pd
assert config['plotly_streaming_domain'] == ps
tls.reset_config_file() # else every would hate me :)


def test_credentials_tools():
original_creds = tls.get_credentials_file()
expected = ['username', 'stream_ids', 'api_key']
assert all(x in original_creds for x in expected)
# now, if that worked, we can try this!
tls.reset_credentials_file()
reset_creds = tls.get_credentials_file()
tls.set_credentials_file(**original_creds)
assert all(x in reset_creds for x in expected)
creds = tls.get_credentials_file()
assert all(x in creds for x in expected)
assert original_creds == creds
=======
from __future__ import absolute_import

import plotly.tools as tls


def test_reset_config_file():
tls.reset_config_file()
config = tls.get_config_file()
assert config['plotly_domain'] == 'https://plot.ly'
assert config['plotly_streaming_domain'] == 'stream.plot.ly'


def test_set_config_file():
pd, ps = 'this', 'thing'
ssl_verify, proxy_auth = True, True
tls.set_config_file(plotly_domain=pd, plotly_streaming_domain=ps,
plotly_ssl_verification=ssl_verify,
plotly_proxy_authorization=proxy_auth)
config = tls.get_config_file()
assert config['plotly_domain'] == pd
assert config['plotly_streaming_domain'] == ps
assert config['plotly_ssl_verification'] == ssl_verify
assert config['plotly_proxy_authorization'] == proxy_auth
tls.reset_config_file() # else every would hate me :)


def test_credentials_tools():
original_creds = tls.get_credentials_file()
expected = ['username', 'stream_ids', 'api_key', 'proxy_username',
'proxy_password']
assert all(x in original_creds for x in expected)

# now, if that worked, we can try this!
tls.reset_credentials_file()
reset_creds = tls.get_credentials_file()
tls.set_credentials_file(**original_creds)
assert all(x in reset_creds for x in expected)
creds = tls.get_credentials_file()
assert all(x in creds for x in expected)
assert original_creds == creds
>>>>>>> afe8b56bb06320a90ce3a404264bc8b3060b87da
Loading
0