Skip to content

Commit fe31851

Browse files
committed
started on tests
1 parent c063f23 commit fe31851

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

plotly/tests/test_core/test_tools/test_file_tools.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from plotly import tools, session
22
from plotly.tests.utils import PlotlyTestCase
33

4+
import ipdb
5+
import warnings
6+
47

58
class FileToolsTest(PlotlyTestCase):
69

@@ -43,14 +46,23 @@ def test_set_config_file_two_entries(self):
4346
self.assertEqual(config['plotly_streaming_domain'], streaming_domain)
4447
tools.reset_config_file()
4548

46-
4749
def test_set_config_file_world_readable(self):
4850

4951
# Return TypeError when world_readable type is not a bool
5052

5153
kwargs = {'world_readable': 'True'}
5254
self.assertRaises(TypeError, tools.set_config_file, **kwargs)
5355

56+
def test_set_config_expected_error_msg(self):
57+
kwargs = {'plotly_domain': 'http://www.foo-bar.com'}
58+
#self.assertRaises(UserWarning, tools.set_config_file, **kwargs)
59+
print 'abcd'
60+
b = tools.set_config_file(**kwargs)
61+
print type(b)
62+
63+
64+
65+
5466
def test_reset_config_file(self):
5567

5668
# Check reset_config and get_config return the same values

plotly/tools.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
)
7474

7575

76-
def validate_domains(*domains):
76+
def _validate_domains(*domains):
7777
for d in domains:
7878
if not d.lower().startswith('https'):
79-
warnings.warn(http_msg)
79+
warnings.warn(http_msg, category=UserWarning)
8080

8181

8282
# Warning format
@@ -255,7 +255,7 @@ def set_config_file(plotly_domain=None,
255255
list_of_domains.append(plotly_domain)
256256
if plotly_api_domain is not None:
257257
list_of_domains.append(plotly_api_domain)
258-
validate_domains(*list_of_domains)
258+
_validate_domains(*list_of_domains)
259259

260260
if isinstance(world_readable, bool):
261261
settings['world_readable'] = world_readable
@@ -272,7 +272,7 @@ def set_config_file(plotly_domain=None,
272272
ensure_local_plotly_files() # make sure what we just put there is OK
273273

274274

275-
def get_config_file(*args, validate=True):
275+
def get_config_file(validate=True, *args):
276276
"""Return specified args from `~/.plotly/.config`. as tuple.
277277
278278
Returns all if no arguments are specified.
@@ -293,13 +293,11 @@ def get_config_file(*args, validate=True):
293293
list_of_domains.append(returned_obj[domain])
294294

295295
if validate:
296-
validate_domains(*list_of_domains)
296+
_validate_domains(*list_of_domains)
297297

298298
return returned_obj
299299

300300

301-
302-
303301
def reset_config_file():
304302
ensure_local_plotly_files() # make sure what's there is OK
305303
f = open(CONFIG_FILE, 'w')

0 commit comments

Comments
 (0)