dataviz: do not accept nested lists as valid data (#51680)
This commit is contained in:
parent
a53f37499a
commit
7cf5e179fe
|
@ -378,7 +378,7 @@ class ChartNgCell(CellBase):
|
|||
x_labels = response['axis'].get('x_labels') or []
|
||||
y_labels = response['axis'].get('y_labels') or []
|
||||
if loop_labels:
|
||||
if x_labels and y_labels:
|
||||
if 'x_labels' in response['axis'] and 'y_labels' in response['axis']:
|
||||
# no support for three dimensions
|
||||
raise UnsupportedDataSet()
|
||||
if not y_labels:
|
||||
|
|
|
@ -126,6 +126,12 @@ VISUALIZATION_JSON = [
|
|||
'name': 'twelth visualization (all null)',
|
||||
'slug': 'twelth',
|
||||
},
|
||||
{
|
||||
'data-url': 'https://bijoe.example.com/visualization/13/json/',
|
||||
'path': 'https://bijoe.example.com/visualization/13/iframe/?signature=123',
|
||||
'name': 'thirteenth visualization (loop with empty x_labels)',
|
||||
'slug': 'thirteenth',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
@ -257,6 +263,17 @@ def bijoe_mock(url, request):
|
|||
'measure': 'integer',
|
||||
}
|
||||
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
|
||||
if url.path == '/visualization/13/json/':
|
||||
response = {
|
||||
'format': '1',
|
||||
'data': [[[], []], [[], []], [[], []]],
|
||||
'axis': {
|
||||
'x_labels': [],
|
||||
'y_labels': ['web', 'mail'],
|
||||
'loop': ['a', 'b', 'c'],
|
||||
},
|
||||
}
|
||||
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
|
||||
|
||||
|
||||
STATISTICS_LIST = {
|
||||
|
@ -477,6 +494,12 @@ def test_chartng_cell(app, statistics):
|
|||
with pytest.raises(HTTPError):
|
||||
chart = cell.get_chart()
|
||||
|
||||
# loop and empty x_labels
|
||||
cell.statistic = Statistic.objects.get(slug='thirteenth')
|
||||
cell.save()
|
||||
with pytest.raises(UnsupportedDataSet):
|
||||
chart = cell.get_chart()
|
||||
|
||||
|
||||
@with_httmock(new_api_mock)
|
||||
def test_chartng_cell_new_api(app, new_api_statistics):
|
||||
|
|
Loading…
Reference in New Issue