Skip to content

Commit f0bc070

Browse files
committed
Update expected JSON encoding of Column dates
1 parent 13e3824 commit f0bc070

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed
Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json as _json
2+
from unittest import TestCase
23

34
import _plotly_utils.utils
45
from chart_studio.grid_objs import Column
@@ -7,19 +8,21 @@
78
mixed_list, np_list
89

910

10-
def test_column_json_encoding():
11-
columns = [
12-
Column(numeric_list, 'col 1'),
13-
Column(mixed_list, 'col 2'),
14-
Column(np_list, 'col 3')
15-
]
16-
json_columns = _json.dumps(
17-
columns, cls=_plotly_utils.utils.PlotlyJSONEncoder, sort_keys=True
18-
)
19-
assert('[{"data": [1, 2, 3], "name": "col 1"}, '
20-
'{"data": [1, "A", "2014-01-05", '
21-
'"2014-01-05 01:01:01", '
22-
'"2014-01-05 01:01:01.000001"], '
23-
'"name": "col 2"}, '
24-
'{"data": [1, 2, 3, null, null, null, '
25-
'"2014-01-05"], "name": "col 3"}]' == json_columns)
11+
class TestJSONEncoder(TestCase):
12+
def test_column_json_encoding(self):
13+
columns = [
14+
Column(numeric_list, 'col 1'),
15+
Column(mixed_list, 'col 2'),
16+
Column(np_list, 'col 3')
17+
]
18+
json_columns = _json.dumps(
19+
columns, cls=_plotly_utils.utils.PlotlyJSONEncoder, sort_keys=True
20+
)
21+
print(json_columns)
22+
assert('[{"data": [1, 2, 3], "name": "col 1"}, '
23+
'{"data": [1, "A", "2014-01-05T00:00:00", '
24+
'"2014-01-05T01:01:01", '
25+
'"2014-01-05T01:01:01.000001"], '
26+
'"name": "col 2"}, '
27+
'{"data": [1, 2, 3, null, null, null, '
28+
'"2014-01-05T00:00:00"], "name": "col 3"}]' == json_columns)

0 commit comments

Comments
 (0)