|
10 | 10 | import random
|
11 | 11 | import string
|
12 | 12 |
|
13 |
| -from nose import with_setup |
14 | 13 | from nose.plugins.attrib import attr
|
15 |
| -from nose.tools import raises |
16 | 14 | from unittest import skip
|
17 | 15 |
|
18 | 16 | import plotly.plotly as py
|
19 | 17 | from plotly.exceptions import PlotlyRequestError
|
20 | 18 | from plotly.grid_objs import Column, Grid
|
| 19 | +from plotly.tests.utils import PlotlyTestCase |
21 | 20 |
|
22 | 21 |
|
23 |
| -def init(): |
24 |
| - py.sign_in('PythonTest', '9v9f20pext') |
| 22 | +class MetaTest(PlotlyTestCase): |
25 | 23 |
|
| 24 | + _grid = grid = Grid([Column([1, 2, 3, 4], 'first column')]) |
| 25 | + _meta = {"settings": {"scope1": {"model": "Unicorn Finder", "voltage": 4}}} |
26 | 26 |
|
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') |
29 | 30 |
|
| 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 |
30 | 35 |
|
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) |
35 | 41 |
|
| 42 | + # Add some Metadata to that grid |
| 43 | + py.meta_ops.upload(self._meta, grid_url=grid_url) |
36 | 44 |
|
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]) |
42 | 49 |
|
43 |
| - # Add some Metadata to that grid |
44 |
| - py.meta_ops.upload(_meta, grid_url=grid_url) |
| 50 | + unique_filename = self.random_filename() |
45 | 51 |
|
| 52 | + py.grid_ops.upload( |
| 53 | + self._grid, |
| 54 | + unique_filename, |
| 55 | + meta=self._meta, |
| 56 | + auto_open=False) |
46 | 57 |
|
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