tests: add test on javascript data rendering (#38908)

This commit is contained in:
Benjamin Dauvergne 2020-01-13 15:11:10 +01:00
parent 5473870dc2
commit 0ddd5530ac
1 changed files with 17 additions and 0 deletions

View File

@ -91,6 +91,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()