dataviz: mark as unsupported arrays with varying lengths (#37899)

This commit is contained in:
Frédéric Péters 2019-11-23 17:48:36 +01:00
parent a87445f075
commit fd93d0b904
2 changed files with 30 additions and 0 deletions

View File

@ -207,6 +207,9 @@ class ChartNgCell(CellBase):
y_labels = loop_labels
else:
x_labels, y_labels = y_labels, loop_labels
if len(y_labels) != len(data) or not all([len(x) == len(x_labels) for x in data]):
# varying dimensions
raise UnsupportedDataSet()
if not x_labels and not y_labels: # unidata
x_labels = ['']
y_labels = ['']

View File

@ -94,6 +94,12 @@ VISUALIZATION_JSON = [
'name': 'eighth visualization (duration)',
'slug': 'eighth',
},
{
'data-url': 'https://bijoe.example.com/visualization/9/json/',
'path': 'https://bijoe.example.com/visualization/9/iframe/?signature=123',
'name': 'nineth visualization (loop over varying dimensions)',
'slug': 'nineth',
},
]
@ -190,6 +196,20 @@ def bijoe_mock(url, request):
'unit': 'seconds',
}
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
if url.path == '/visualization/9/json/':
response = {
'format': '1',
'data': [
[1, 1, 1, 1],
[1],
[1, 1],
],
'axis': {
'y_labels': ['web', 'mail', 'email'],
'loop': ['a', 'b', 'c', 'd'],
}
}
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
def test_chartng_cell(app):
@ -293,6 +313,12 @@ def test_chartng_cell(app):
cell.save()
chart = cell.get_chart()
# loop/X/Y
cell.data_reference = 'plop:nineth'
cell.save()
with pytest.raises(UnsupportedDataSet):
chart = cell.get_chart()
def test_chartng_cell_view(app, normal_user):
page = Page(title='One', slug='index')
@ -390,6 +416,7 @@ def test_chartng_cell_manager(app, admin_user):
(u'plop:example', True, u'example visualization (X)'),
(u'plop:fifth', False, u'fifth visualization (loop/X)'),
(u'plop:fourth', False, u'fourth visualization (no axis)'),
(u'plop:nineth', False, u'nineth visualization (loop over varying dimensions)'),
(u'plop:second', False, u'second visualization (Y)'),
(u'plop:seventh', False, u'seventh visualization (loop/X/Y)'),
(u'plop:sixth', False, u'sixth visualization (loop/Y)'),