118 |
118 |
'data': [222, 134, 53],
|
119 |
119 |
'axis': {
|
120 |
120 |
'x_labels': ['web', 'mail', 'email']
|
121 |
|
}
|
|
121 |
},
|
|
122 |
'measure': 'integer',
|
122 |
123 |
}
|
123 |
124 |
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
|
124 |
125 |
if url.path == '/visualization/2/json/':
|
... | ... | |
127 |
128 |
'data': [222, 134, 53],
|
128 |
129 |
'axis': {
|
129 |
130 |
'y_labels': ['web', 'mail', 'email']
|
130 |
|
}
|
|
131 |
},
|
|
132 |
'measure': 'integer',
|
131 |
133 |
}
|
132 |
134 |
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
|
133 |
135 |
if url.path == '/visualization/3/json/':
|
... | ... | |
140 |
142 |
'axis': {
|
141 |
143 |
'x_labels': ['web', 'mail', 'email'],
|
142 |
144 |
'y_labels': ['foo', 'bar'],
|
143 |
|
}
|
|
145 |
},
|
|
146 |
'measure': 'integer',
|
144 |
147 |
}
|
145 |
148 |
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
|
146 |
149 |
if url.path == '/visualization/4/json/':
|
147 |
150 |
response = {
|
148 |
151 |
'format': '1',
|
149 |
152 |
'data': 222,
|
150 |
|
'axis': {}
|
|
153 |
'axis': {},
|
|
154 |
'measure': 'integer',
|
151 |
155 |
}
|
152 |
156 |
return {'content': json.dumps(response), 'request': request, 'status_code': 200}
|
153 |
157 |
if url.path == '/visualization/5/json/':
|
... | ... | |
455 |
459 |
(u'plop:tenth', False, u'tenth visualization (percents)'),
|
456 |
460 |
(u'plop:third', False, u'third visualization (X/Y)'),
|
457 |
461 |
]
|
|
462 |
|
|
463 |
|
|
464 |
def test_table_cell(app, admin_user):
|
|
465 |
page = Page(title='One', slug='index')
|
|
466 |
page.save()
|
|
467 |
|
|
468 |
app = login(app)
|
|
469 |
|
|
470 |
with override_settings(KNOWN_SERVICES={
|
|
471 |
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
|
472 |
'secret': 'combo', 'orig': 'combo'}}}):
|
|
473 |
with HTTMock(bijoe_mock):
|
|
474 |
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
|
475 |
cell.data_reference = 'plop:example'
|
|
476 |
cell.chart_type = 'table'
|
|
477 |
cell.save()
|
|
478 |
resp = app.get('/api/dataviz/graph/1/')
|
|
479 |
resp = app.get('/')
|
|
480 |
assert resp.text.count('Total') == 1
|
|
481 |
|
|
482 |
cell.data_reference = 'plop:second'
|
|
483 |
cell.save()
|
|
484 |
resp = app.get('/api/dataviz/graph/1/')
|
|
485 |
resp = app.get('/')
|
|
486 |
assert resp.text.count('Total') == 1
|
|
487 |
|
|
488 |
cell.data_reference = 'plop:third'
|
|
489 |
cell.save()
|
|
490 |
resp = app.get('/api/dataviz/graph/1/')
|
|
491 |
resp = app.get('/')
|
|
492 |
assert '114' in resp.text
|
|
493 |
assert resp.text.count('Total') == 2
|
|
494 |
|
|
495 |
cell.data_reference = 'plop:fourth'
|
|
496 |
cell.save()
|
|
497 |
resp = app.get('/api/dataviz/graph/1/')
|
|
498 |
resp = app.get('/')
|
|
499 |
assert resp.text.count('Total') == 0
|
|
500 |
|
|
501 |
# total of durations is not computed
|
|
502 |
cell.data_reference = 'plop:eigth'
|
|
503 |
cell.save()
|
|
504 |
resp = app.get('/api/dataviz/graph/1/')
|
|
505 |
resp = app.get('/')
|
|
506 |
assert resp.text.count('Total') == 0
|
458 |
|
-
|