From a54660d1f8ed65d8008c407baeb57ebc1360e9ff Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 13 Jan 2020 15:11:10 +0100 Subject: [PATCH 1/3] tests: add test on javascript data rendering --- tests/test_schema1.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_schema1.py b/tests/test_schema1.py index 5919f11..c1179fd 100644 --- a/tests/test_schema1.py +++ b/tests/test_schema1.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- +import json + from utils import login, get_table, get_ods_table, get_ods_document from bijoe.visualization.ods import OFFICE_NS, TABLE_NS +from bijoe.visualization.utils import Visualization def test_simple(schema1, app, admin): @@ -87,6 +90,23 @@ def test_string_dimension(schema1, app, admin): assert get_table(response) == [['String', 'a', 'b', 'c', 'Aucun(e)'], ['number of rows', '11', '2', '0', '1']] +def test_string_dimension_json_data(schema1, app, admin): + # test conversion to Javascript declaration + visu = Visualization.from_json({ + 'warehouse': 'schema1', + 'cube': 'facts1', + 'representation': 'table', + 'measure': 'simple_count', + 'drilldown_x': 'string' + }) + assert json.loads(json.dumps(visu.json_data())) == [ + {u'coords': [{u'value': u'a'}], u'measures': [{u'value': 11}]}, + {u'coords': [{u'value': u'b'}], u'measures': [{u'value': 2}]}, + {u'coords': [{u'value': u'c'}], u'measures': [{u'value': 3}]}, + {u'coords': [{u'value': u'Aucun(e)'}], u'measures': [{u'value': 1}]} + ] + + def test_item_dimension(schema1, app, admin): login(app, admin) response = app.get('/').follow() -- 2.24.0