Projet

Général

Profil

0001-tests-add-test-on-json_data-for-None-measures-38913.patch

Benjamin Dauvergne, 14 janvier 2020 17:55

Télécharger (1,96 ko)

Voir les différences:

Subject: [PATCH 1/3] tests: add test on json_data for None measures (#38913)

 tests/test_schema1.py | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
tests/test_schema1.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import json
4

  
3 5
from utils import login, get_table, get_ods_table, get_ods_document
4 6

  
5 7
from bijoe.visualization.ods import OFFICE_NS, TABLE_NS
8
from bijoe.visualization.utils import Visualization
6 9

  
7 10

  
8 11
def test_simple(schema1, app, admin):
......
173 176
        ['', 'janvier', u'f\xe9vrier', 'mars', 'avril', 'mai', 'juin', 'juillet', u'ao\xfbt', 'Total'],
174 177
        ['2017', '10', '1', '1', '1', '1', '1', '1', '1', '17'],
175 178
    ]
179

  
180

  
181
def test_none_percent_json_data(schema1, app, admin):
182
    # test conversion to Javascript declaration
183
    visu = Visualization.from_json({
184
        'warehouse': 'schema1',
185
        'cube': 'facts1',
186
        'representation': 'graphical',
187
        'measure': 'percent',
188
        'drilldown_y': 'leftcategory',
189
        'drilldown_x': 'date__year',
190
    })
191
    assert visu.json_data() == [
192
        {
193
            'coords': [{'value': u'2017'}, {'value': u'cat\xe92'}],
194
            'measures': [{'value': None}]
195
        },
196
        {
197
            'coords': [{'value': u'2017'}, {'value': u'cat\xe93'}],
198
            'measures': [{'value': None}]},
199
        {
200
            'coords': [{'value': u'2017'}, {'value': u'cat\xe91'}],
201
            'measures': [{'value': 94.11764705882354}]},
202
        {
203
            'coords': [{'value': u'2017'}, {'value': u'Aucun(e)'}],
204
            'measures': [{'value': 5.882352941176471}]
205
        }
206
    ]
176
-