tests: add test on JSON dimensions (#41814)
This commit is contained in:
parent
7cab96b989
commit
46b5349f93
|
@ -242,7 +242,8 @@
|
|||
"warnings": [
|
||||
"le champ \u00ab pou\u00ebt \u00bb n'est pas bon",
|
||||
"warning2"
|
||||
]
|
||||
],
|
||||
"json_field": "json"
|
||||
}
|
||||
],
|
||||
"label": "test schema1",
|
||||
|
|
|
@ -27,7 +27,8 @@ CREATE TABLE "Facts" (
|
|||
rightsubcategory_id integer references schema1.subcategory(id),
|
||||
outersubcategory_id integer references schema1.subcategory(id),
|
||||
"String" varchar,
|
||||
geo point
|
||||
geo point,
|
||||
json jsonb
|
||||
);
|
||||
|
||||
INSERT INTO category (ord, label) VALUES
|
||||
|
@ -47,21 +48,21 @@ INSERT INTO subcategory (category_id, ord, label) VALUES
|
|||
(3, 0, 'subé9');
|
||||
|
||||
|
||||
INSERT INTO "Facts" (date, datetime, integer, boolean, cnt, innersubcategory_id, leftsubcategory_id, rightsubcategory_id, outersubcategory_id, "String", geo) VALUES
|
||||
('2017-01-01', '2017-01-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-01-02', '2017-01-02 10:00', 1, TRUE, 10, 3, 3, 3, 3, 'b', '(1, 1)'),
|
||||
('2017-01-03', '2017-01-03 10:00', 1, FALSE, 10, NULL, NULL, NULL, NULL, 'a', '(1, 1)'),
|
||||
('2017-01-04', '2017-01-04 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-01-05', '2017-01-05 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'c', '(1, 1)'),
|
||||
('2017-01-06', '2017-01-06 10:00', 1, FALSE, 10, 1, 1, 1, 1, NULL, '(1, 1)'),
|
||||
('2017-01-07', '2017-01-07 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-01-08', '2017-01-08 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-01-09', '2017-01-09 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-01-10', '2017-01-10 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-02-01', '2017-02-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-03-01', '2017-03-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'c', '(1, 1)'),
|
||||
('2017-04-01', '2017-04-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-05-01', '2017-05-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-06-01', '2017-06-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'c', '(1, 1)'),
|
||||
('2017-07-01', '2017-07-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)'),
|
||||
('2017-08-01', '2017-08-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'b', '(1, 1)');
|
||||
INSERT INTO "Facts" (date, datetime, integer, boolean, cnt, innersubcategory_id, leftsubcategory_id, rightsubcategory_id, outersubcategory_id, "String", geo, json) VALUES
|
||||
('2017-01-01', '2017-01-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "x"}'),
|
||||
('2017-01-02', '2017-01-02 10:00', 1, TRUE, 10, 3, 3, 3, 3, 'b', '(1, 1)', '{"a": "x"}'),
|
||||
('2017-01-03', '2017-01-03 10:00', 1, FALSE, 10, NULL, NULL, NULL, NULL, 'a', '(1, 1)', '{"a": "x"}'),
|
||||
('2017-01-04', '2017-01-04 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "x"}'),
|
||||
('2017-01-05', '2017-01-05 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'c', '(1, 1)', '{"a": "x"}'),
|
||||
('2017-01-06', '2017-01-06 10:00', 1, FALSE, 10, 1, 1, 1, 1, NULL, '(1, 1)', '{"a": "x"}'),
|
||||
('2017-01-07', '2017-01-07 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "x"}'),
|
||||
('2017-01-08', '2017-01-08 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-01-09', '2017-01-09 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-01-10', '2017-01-10 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-02-01', '2017-02-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-03-01', '2017-03-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'c', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-04-01', '2017-04-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-05-01', '2017-05-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-06-01', '2017-06-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'c', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-07-01', '2017-07-01 10:00', 1, FALSE, 10, 1, 1, 1, 1, 'a', '(1, 1)', '{"a": "y"}'),
|
||||
('2017-08-01', '2017-08-01 10:00', 1, TRUE, 10, 1, 1, 1, 1, 'b', '(1, 1)', '{"a": "z"}');
|
||||
|
|
|
@ -348,3 +348,30 @@ def test_empty_filter(schema1, app, admin):
|
|||
}
|
||||
})
|
||||
assert visu.json_data() == [{'coords': [], 'measures': [{'value': 17}]}]
|
||||
|
||||
|
||||
def test_json_dimensions(schema1, app, admin):
|
||||
login(app, admin)
|
||||
response = app.get('/')
|
||||
response = response.click('schema1')
|
||||
response = response.click('Facts 1')
|
||||
form = response.form
|
||||
|
||||
form.set('representation', 'table')
|
||||
form.set('measure', 'simple_count')
|
||||
form.set('drilldown_x', 'a')
|
||||
response = form.submit('visualize')
|
||||
assert get_table(response) == [
|
||||
['A', 'x', 'y', 'z'],
|
||||
['number of rows', '7', '9', '1']
|
||||
]
|
||||
|
||||
assert 'filter__a' in form.fields
|
||||
assert set([o[0] for o in form['filter__a'].options]) == {'x', 'y', 'z', '__none__'}
|
||||
|
||||
form.set('filter__a', ['x', 'y'])
|
||||
response = form.submit('visualize')
|
||||
assert get_table(response) == [
|
||||
['A', 'x', 'y', 'z'],
|
||||
['number of rows', '7', '9', '0']
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue