Projet

Général

Profil

0001-dataviz-mark-as-unsupported-arrays-with-varying-leng.patch

Frédéric Péters, 23 novembre 2019 17:52

Télécharger (3,22 ko)

Voir les différences:

Subject: [PATCH] dataviz: mark as unsupported arrays with varying lengths
 (#37899)

 combo/apps/dataviz/models.py |  3 +++
 tests/test_dataviz.py        | 27 +++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
combo/apps/dataviz/models.py
207 207
                y_labels = loop_labels
208 208
            else:
209 209
                x_labels, y_labels = y_labels, loop_labels
210
            if len(y_labels) != len(data) or not all([len(x) == len(x_labels) for x in data]):
211
                # varying dimensions
212
                raise UnsupportedDataSet()
210 213
        if not x_labels and not y_labels:  # unidata
211 214
            x_labels = ['']
212 215
            y_labels = ['']
tests/test_dataviz.py
94 94
        'name': 'eighth visualization (duration)',
95 95
        'slug': 'eighth',
96 96
    },
97
    {
98
        'data-url': 'https://bijoe.example.com/visualization/9/json/',
99
        'path': 'https://bijoe.example.com/visualization/9/iframe/?signature=123',
100
        'name': 'nineth visualization (loop over varying dimensions)',
101
        'slug': 'nineth',
102
    },
97 103
]
98 104

  
99 105

  
......
190 196
            'unit': 'seconds',
191 197
        }
192 198
        return {'content': json.dumps(response), 'request': request, 'status_code': 200}
199
    if url.path == '/visualization/9/json/':
200
        response = {
201
            'format': '1',
202
            'data': [
203
                [1, 1, 1, 1],
204
                [1],
205
                [1, 1],
206
            ],
207
            'axis': {
208
                'y_labels': ['web', 'mail', 'email'],
209
                'loop': ['a', 'b', 'c', 'd'],
210
            }
211
        }
212
        return {'content': json.dumps(response), 'request': request, 'status_code': 200}
193 213

  
194 214

  
195 215
def test_chartng_cell(app):
......
293 313
            cell.save()
294 314
            chart = cell.get_chart()
295 315

  
316
            # loop/X/Y
317
            cell.data_reference = 'plop:nineth'
318
            cell.save()
319
            with pytest.raises(UnsupportedDataSet):
320
                chart = cell.get_chart()
321

  
296 322

  
297 323
def test_chartng_cell_view(app, normal_user):
298 324
    page = Page(title='One', slug='index')
......
390 416
                (u'plop:example', True, u'example visualization (X)'),
391 417
                (u'plop:fifth', False, u'fifth visualization (loop/X)'),
392 418
                (u'plop:fourth', False, u'fourth visualization (no axis)'),
419
                (u'plop:nineth', False, u'nineth visualization (loop over varying dimensions)'),
393 420
                (u'plop:second', False, u'second visualization (Y)'),
394 421
                (u'plop:seventh', False, u'seventh visualization (loop/X/Y)'),
395 422
                (u'plop:sixth', False, u'sixth visualization (loop/Y)'),
396
-