Skip to content

Commit 75c81df

Browse files
committed
🔧 Cleanup test_meta.py.
1 parent 451d349 commit 75c81df

File tree

1 file changed

+34
-41
lines changed

1 file changed

+34
-41
lines changed

plotly/tests/test_core/test_meta/test_meta.py

+34-41
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,54 @@
1010
import random
1111
import string
1212

13-
from nose import with_setup
1413
from nose.plugins.attrib import attr
15-
from nose.tools import raises
1614
from unittest import skip
1715

1816
import plotly.plotly as py
1917
from plotly.exceptions import PlotlyRequestError
2018
from plotly.grid_objs import Column, Grid
19+
from plotly.tests.utils import PlotlyTestCase
2120

2221

23-
def init():
24-
py.sign_in('PythonTest', '9v9f20pext')
22+
class MetaTest(PlotlyTestCase):
2523

24+
_grid = grid = Grid([Column([1, 2, 3, 4], 'first column')])
25+
_meta = {"settings": {"scope1": {"model": "Unicorn Finder", "voltage": 4}}}
2626

27-
_grid = grid = Grid([Column([1, 2, 3, 4], 'first column')])
28-
_meta = {"settings": {"scope1": {"model": "Unicorn Finder", "voltage": 4}}}
27+
def setUp(self):
28+
super(MetaTest, self).setUp()
29+
py.sign_in('PythonTest', '9v9f20pext')
2930

31+
def random_filename(self):
32+
random_chars = [random.choice(string.ascii_uppercase) for _ in range(5)]
33+
unique_filename = 'Valid Grid with Meta '+''.join(random_chars)
34+
return unique_filename
3035

31-
def _random_filename():
32-
random_chars = [random.choice(string.ascii_uppercase) for _ in range(5)]
33-
unique_filename = 'Valid Grid with Meta '+''.join(random_chars)
34-
return unique_filename
36+
@attr('slow')
37+
def test_upload_meta(self):
38+
unique_filename = self.random_filename()
39+
grid_url = py.grid_ops.upload(self._grid, unique_filename,
40+
auto_open=False)
3541

42+
# Add some Metadata to that grid
43+
py.meta_ops.upload(self._meta, grid_url=grid_url)
3644

37-
@attr('slow')
38-
@with_setup(init)
39-
def test_upload_meta():
40-
unique_filename = _random_filename()
41-
grid_url = py.grid_ops.upload(_grid, unique_filename, auto_open=False)
45+
@attr('slow')
46+
def test_upload_meta_with_grid(self):
47+
c1 = Column([1, 2, 3, 4], 'first column')
48+
Grid([c1])
4249

43-
# Add some Metadata to that grid
44-
py.meta_ops.upload(_meta, grid_url=grid_url)
50+
unique_filename = self.random_filename()
4551

52+
py.grid_ops.upload(
53+
self._grid,
54+
unique_filename,
55+
meta=self._meta,
56+
auto_open=False)
4657

47-
@attr('slow')
48-
@with_setup(init)
49-
def test_upload_meta_with_grid():
50-
c1 = Column([1, 2, 3, 4], 'first column')
51-
Grid([c1])
52-
53-
unique_filename = _random_filename()
54-
55-
py.grid_ops.upload(
56-
_grid,
57-
unique_filename,
58-
meta=_meta,
59-
auto_open=False)
60-
61-
62-
@skip('adding this for now so test_file_tools pass, more info' +
63-
'https://github.com/plotly/python-api/issues/263')
64-
@raises(PlotlyRequestError)
65-
def test_metadata_to_nonexistent_grid():
66-
init()
67-
68-
non_exist_meta_url = 'https://local.plot.ly/~GridTest/999999999'
69-
70-
py.meta_ops.upload(_meta, grid_url=non_exist_meta_url)
58+
@skip('adding this for now so test_file_tools pass, more info' +
59+
'https://github.com/plotly/python-api/issues/263')
60+
def test_metadata_to_nonexistent_grid(self):
61+
non_exist_meta_url = 'https://local.plot.ly/~GridTest/999999999'
62+
with self.assertRaises(PlotlyRequestError):
63+
py.meta_ops.upload(self._meta, grid_url=non_exist_meta_url)

0 commit comments

Comments
 (0)