2 |
2 |
|
3 |
3 |
import mock
|
4 |
4 |
import pytest
|
5 |
|
from httmock import HTTMock
|
|
5 |
from httmock import HTTMock, with_httmock
|
6 |
6 |
from requests.exceptions import HTTPError
|
7 |
7 |
|
|
8 |
from django.apps import apps
|
8 |
9 |
from django.contrib.auth.models import User, Group
|
9 |
10 |
from django.test import override_settings
|
10 |
11 |
|
... | ... | |
27 |
28 |
return cell
|
28 |
29 |
|
29 |
30 |
|
|
31 |
@pytest.fixture(autouse=True)
|
|
32 |
def bijoe_settings(settings):
|
|
33 |
settings.KNOWN_SERVICES = {
|
|
34 |
"bijoe": {
|
|
35 |
"plop": {"title": "test", "url": "https://bijoe.example.com", "secret": "combo", "orig": "combo"}
|
|
36 |
}
|
|
37 |
}
|
|
38 |
|
|
39 |
|
30 |
40 |
def test_jsonp_gauge(app, cell):
|
31 |
41 |
with override_settings(TEMPLATE_VARS={'test_url': 'http://www.example.net'}):
|
32 |
42 |
resp = app.get('/')
|
... | ... | |
247 |
257 |
|
248 |
258 |
|
249 |
259 |
|
|
260 |
@with_httmock(bijoe_mock)
|
250 |
261 |
def test_chartng_cell(app):
|
251 |
262 |
page = Page(title='One', slug='index')
|
252 |
263 |
page.save()
|
253 |
264 |
|
254 |
|
with override_settings(KNOWN_SERVICES={
|
255 |
|
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
256 |
|
'secret': 'combo', 'orig': 'combo'}}}):
|
257 |
|
with HTTMock(bijoe_mock):
|
258 |
|
cell = ChartNgCell(page=page, order=1)
|
259 |
|
cell.data_reference = 'plop:example'
|
260 |
|
cell.save()
|
261 |
|
assert cell.cached_json == VISUALIZATION_JSON[0]
|
262 |
|
|
263 |
|
# bar
|
264 |
|
chart = cell.get_chart()
|
265 |
|
assert chart.__class__.__name__ == 'Bar'
|
266 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
267 |
|
assert chart.raw_series == [([222, 134, 0, 53], {'title': ''})]
|
268 |
|
|
269 |
|
# horizontal bar
|
270 |
|
cell.chart_type = 'horizontal-bar'
|
271 |
|
chart = cell.get_chart()
|
272 |
|
assert chart.__class__.__name__ == 'HorizontalBar'
|
273 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
274 |
|
assert chart.raw_series == [([222, 134, 0, 53], {'title': ''})]
|
275 |
|
|
276 |
|
# pie
|
277 |
|
cell.chart_type = 'pie'
|
278 |
|
chart = cell.get_chart()
|
279 |
|
assert chart.__class__.__name__ == 'Pie'
|
280 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
281 |
|
assert chart.raw_series == [
|
282 |
|
([222], {'title': u'web'}),
|
283 |
|
([134], {'title': u'mail'}),
|
284 |
|
([53], {'title': u'email'})
|
285 |
|
]
|
286 |
|
|
287 |
|
# data in Y
|
288 |
|
cell.chart_type = 'bar'
|
289 |
|
cell.data_reference = 'plop:second'
|
290 |
|
cell.save()
|
291 |
|
assert cell.cached_json == VISUALIZATION_JSON[1]
|
292 |
|
|
293 |
|
chart = cell.get_chart()
|
294 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
295 |
|
assert chart.raw_series == [([222, 134, 0, 53], {'title': ''})]
|
296 |
|
|
297 |
|
# data in X/Y
|
298 |
|
cell.chart_type = 'bar'
|
299 |
|
cell.data_reference = 'plop:third'
|
300 |
|
cell.save()
|
301 |
|
assert cell.cached_json == VISUALIZATION_JSON[2]
|
302 |
|
|
303 |
|
chart = cell.get_chart()
|
304 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
305 |
|
assert chart.raw_series == [
|
306 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
307 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
308 |
|
]
|
309 |
|
|
310 |
|
# single data point
|
311 |
|
cell.chart_type = 'bar'
|
312 |
|
cell.data_reference = 'plop:fourth'
|
313 |
|
cell.save()
|
314 |
|
assert cell.cached_json == VISUALIZATION_JSON[3]
|
315 |
|
|
316 |
|
chart = cell.get_chart()
|
317 |
|
assert chart.x_labels == ['']
|
318 |
|
assert chart.raw_series == [([222], {'title': ''})]
|
319 |
|
|
320 |
|
# loop/X
|
321 |
|
cell.data_reference = 'plop:fifth'
|
322 |
|
cell.save()
|
323 |
|
chart = cell.get_chart()
|
324 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
325 |
|
assert chart.raw_series == [
|
326 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
327 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
328 |
|
]
|
329 |
|
|
330 |
|
# loop/Y
|
331 |
|
cell.data_reference = 'plop:sixth'
|
332 |
|
cell.save()
|
333 |
|
chart = cell.get_chart()
|
334 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
335 |
|
assert chart.raw_series == [
|
336 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
337 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
338 |
|
]
|
339 |
|
|
340 |
|
# loop/X/Y
|
341 |
|
cell.data_reference = 'plop:seventh'
|
342 |
|
cell.save()
|
343 |
|
with pytest.raises(UnsupportedDataSet):
|
344 |
|
chart = cell.get_chart()
|
345 |
|
|
346 |
|
# duration
|
347 |
|
cell.data_reference = 'plop:eighth'
|
348 |
|
cell.save()
|
349 |
|
chart = cell.get_chart()
|
350 |
|
|
351 |
|
# loop/X/Y
|
352 |
|
cell.data_reference = 'plop:nineth'
|
353 |
|
cell.save()
|
354 |
|
with pytest.raises(UnsupportedDataSet):
|
355 |
|
chart = cell.get_chart()
|
356 |
|
|
357 |
|
# deleted visualization
|
358 |
|
cell.data_reference = 'plop:eleventh'
|
359 |
|
cell.save()
|
360 |
|
with pytest.raises(HTTPError):
|
361 |
|
chart = cell.get_chart()
|
|
265 |
cell = ChartNgCell(page=page, order=1)
|
|
266 |
cell.data_reference = 'plop:example'
|
|
267 |
cell.save()
|
|
268 |
assert cell.cached_json == VISUALIZATION_JSON[0]
|
|
269 |
|
|
270 |
# bar
|
|
271 |
chart = cell.get_chart()
|
|
272 |
assert chart.__class__.__name__ == 'Bar'
|
|
273 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
274 |
assert chart.raw_series == [([222, 134, 0, 53], {'title': ''})]
|
|
275 |
|
|
276 |
# horizontal bar
|
|
277 |
cell.chart_type = 'horizontal-bar'
|
|
278 |
chart = cell.get_chart()
|
|
279 |
assert chart.__class__.__name__ == 'HorizontalBar'
|
|
280 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
281 |
assert chart.raw_series == [([222, 134, 0, 53], {'title': ''})]
|
|
282 |
|
|
283 |
# pie
|
|
284 |
cell.chart_type = 'pie'
|
|
285 |
chart = cell.get_chart()
|
|
286 |
assert chart.__class__.__name__ == 'Pie'
|
|
287 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
288 |
assert chart.raw_series == [
|
|
289 |
([222], {'title': u'web'}),
|
|
290 |
([134], {'title': u'mail'}),
|
|
291 |
([53], {'title': u'email'})
|
|
292 |
]
|
|
293 |
|
|
294 |
# data in Y
|
|
295 |
cell.chart_type = 'bar'
|
|
296 |
cell.data_reference = 'plop:second'
|
|
297 |
cell.save()
|
|
298 |
assert cell.cached_json == VISUALIZATION_JSON[1]
|
|
299 |
|
|
300 |
chart = cell.get_chart()
|
|
301 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
302 |
assert chart.raw_series == [([222, 134, 0, 53], {'title': ''})]
|
|
303 |
|
|
304 |
# data in X/Y
|
|
305 |
cell.chart_type = 'bar'
|
|
306 |
cell.data_reference = 'plop:third'
|
|
307 |
cell.save()
|
|
308 |
assert cell.cached_json == VISUALIZATION_JSON[2]
|
|
309 |
|
|
310 |
chart = cell.get_chart()
|
|
311 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
312 |
assert chart.raw_series == [
|
|
313 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
314 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
315 |
]
|
|
316 |
|
|
317 |
# single data point
|
|
318 |
cell.chart_type = 'bar'
|
|
319 |
cell.data_reference = 'plop:fourth'
|
|
320 |
cell.save()
|
|
321 |
assert cell.cached_json == VISUALIZATION_JSON[3]
|
|
322 |
|
|
323 |
chart = cell.get_chart()
|
|
324 |
assert chart.x_labels == ['']
|
|
325 |
assert chart.raw_series == [([222], {'title': ''})]
|
|
326 |
|
|
327 |
# loop/X
|
|
328 |
cell.data_reference = 'plop:fifth'
|
|
329 |
cell.save()
|
|
330 |
chart = cell.get_chart()
|
|
331 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
332 |
assert chart.raw_series == [
|
|
333 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
334 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
335 |
]
|
|
336 |
|
|
337 |
# loop/Y
|
|
338 |
cell.data_reference = 'plop:sixth'
|
|
339 |
cell.save()
|
|
340 |
chart = cell.get_chart()
|
|
341 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
342 |
assert chart.raw_series == [
|
|
343 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
344 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
345 |
]
|
|
346 |
|
|
347 |
# loop/X/Y
|
|
348 |
cell.data_reference = 'plop:seventh'
|
|
349 |
cell.save()
|
|
350 |
with pytest.raises(UnsupportedDataSet):
|
|
351 |
chart = cell.get_chart()
|
|
352 |
|
|
353 |
# duration
|
|
354 |
cell.data_reference = 'plop:eighth'
|
|
355 |
cell.save()
|
|
356 |
chart = cell.get_chart()
|
|
357 |
|
|
358 |
# loop/X/Y
|
|
359 |
cell.data_reference = 'plop:nineth'
|
|
360 |
cell.save()
|
|
361 |
with pytest.raises(UnsupportedDataSet):
|
|
362 |
chart = cell.get_chart()
|
|
363 |
|
|
364 |
# deleted visualization
|
|
365 |
cell.data_reference = 'plop:eleventh'
|
|
366 |
cell.save()
|
|
367 |
with pytest.raises(HTTPError):
|
|
368 |
chart = cell.get_chart()
|
362 |
369 |
|
363 |
370 |
|
|
371 |
@with_httmock(bijoe_mock)
|
364 |
372 |
def test_chartng_cell_hide_null_values(app):
|
365 |
373 |
page = Page(title='One', slug='index')
|
366 |
374 |
page.save()
|
367 |
375 |
|
368 |
|
with override_settings(KNOWN_SERVICES={
|
369 |
|
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
370 |
|
'secret': 'combo', 'orig': 'combo'}}}):
|
371 |
|
with HTTMock(bijoe_mock):
|
372 |
|
cell = ChartNgCell(page=page, order=1)
|
373 |
|
cell.data_reference = 'plop:example'
|
374 |
|
cell.hide_null_values = True
|
375 |
|
cell.save()
|
376 |
|
assert cell.cached_json == VISUALIZATION_JSON[0]
|
377 |
|
|
378 |
|
# bar
|
379 |
|
chart = cell.get_chart()
|
380 |
|
assert chart.__class__.__name__ == 'Bar'
|
381 |
|
assert chart.x_labels == ['web', 'mail', 'email']
|
382 |
|
assert chart.raw_series == [([222, 134, 53], {'title': ''})]
|
383 |
|
|
384 |
|
# horizontal bar
|
385 |
|
cell.chart_type = 'horizontal-bar'
|
386 |
|
chart = cell.get_chart()
|
387 |
|
assert chart.__class__.__name__ == 'HorizontalBar'
|
388 |
|
assert chart.x_labels == ['web', 'mail', 'email']
|
389 |
|
assert chart.raw_series == [([222, 134, 53], {'title': ''})]
|
390 |
|
|
391 |
|
# pie
|
392 |
|
cell.chart_type = 'pie'
|
393 |
|
chart = cell.get_chart()
|
394 |
|
assert chart.__class__.__name__ == 'Pie'
|
395 |
|
assert chart.x_labels == ['web', 'mail', 'email']
|
396 |
|
assert chart.raw_series == [
|
397 |
|
([222], {'title': u'web'}),
|
398 |
|
([134], {'title': u'mail'}),
|
399 |
|
([53], {'title': u'email'})
|
400 |
|
]
|
401 |
|
|
402 |
|
# data in Y
|
403 |
|
cell.chart_type = 'bar'
|
404 |
|
cell.data_reference = 'plop:second'
|
405 |
|
cell.save()
|
406 |
|
assert cell.cached_json == VISUALIZATION_JSON[1]
|
407 |
|
|
408 |
|
chart = cell.get_chart()
|
409 |
|
assert chart.x_labels == ['web', 'mail', 'email']
|
410 |
|
assert chart.raw_series == [([222, 134, 53], {'title': ''})]
|
411 |
|
|
412 |
|
# data in X/Y
|
413 |
|
cell.chart_type = 'bar'
|
414 |
|
cell.data_reference = 'plop:third'
|
415 |
|
cell.save()
|
416 |
|
assert cell.cached_json == VISUALIZATION_JSON[2]
|
417 |
|
|
418 |
|
chart = cell.get_chart()
|
419 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
420 |
|
assert chart.raw_series == [
|
421 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
422 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
423 |
|
]
|
424 |
|
|
425 |
|
# single data point
|
426 |
|
cell.chart_type = 'bar'
|
427 |
|
cell.data_reference = 'plop:fourth'
|
428 |
|
cell.save()
|
429 |
|
assert cell.cached_json == VISUALIZATION_JSON[3]
|
430 |
|
|
431 |
|
chart = cell.get_chart()
|
432 |
|
assert chart.x_labels == ['']
|
433 |
|
assert chart.raw_series == [([222], {'title': ''})]
|
434 |
|
|
435 |
|
# loop/X
|
436 |
|
cell.data_reference = 'plop:fifth'
|
437 |
|
cell.save()
|
438 |
|
chart = cell.get_chart()
|
439 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
440 |
|
assert chart.raw_series == [
|
441 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
442 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
443 |
|
]
|
444 |
|
|
445 |
|
# loop/Y
|
446 |
|
cell.data_reference = 'plop:sixth'
|
447 |
|
cell.save()
|
448 |
|
chart = cell.get_chart()
|
449 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
450 |
|
assert chart.raw_series == [
|
451 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
452 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
453 |
|
]
|
|
376 |
cell = ChartNgCell(page=page, order=1)
|
|
377 |
cell.data_reference = 'plop:example'
|
|
378 |
cell.hide_null_values = True
|
|
379 |
cell.save()
|
|
380 |
assert cell.cached_json == VISUALIZATION_JSON[0]
|
|
381 |
|
|
382 |
# bar
|
|
383 |
chart = cell.get_chart()
|
|
384 |
assert chart.__class__.__name__ == 'Bar'
|
|
385 |
assert chart.x_labels == ['web', 'mail', 'email']
|
|
386 |
assert chart.raw_series == [([222, 134, 53], {'title': ''})]
|
|
387 |
|
|
388 |
# horizontal bar
|
|
389 |
cell.chart_type = 'horizontal-bar'
|
|
390 |
chart = cell.get_chart()
|
|
391 |
assert chart.__class__.__name__ == 'HorizontalBar'
|
|
392 |
assert chart.x_labels == ['web', 'mail', 'email']
|
|
393 |
assert chart.raw_series == [([222, 134, 53], {'title': ''})]
|
|
394 |
|
|
395 |
# pie
|
|
396 |
cell.chart_type = 'pie'
|
|
397 |
chart = cell.get_chart()
|
|
398 |
assert chart.__class__.__name__ == 'Pie'
|
|
399 |
assert chart.x_labels == ['web', 'mail', 'email']
|
|
400 |
assert chart.raw_series == [
|
|
401 |
([222], {'title': u'web'}),
|
|
402 |
([134], {'title': u'mail'}),
|
|
403 |
([53], {'title': u'email'})
|
|
404 |
]
|
|
405 |
|
|
406 |
# data in Y
|
|
407 |
cell.chart_type = 'bar'
|
|
408 |
cell.data_reference = 'plop:second'
|
|
409 |
cell.save()
|
|
410 |
assert cell.cached_json == VISUALIZATION_JSON[1]
|
454 |
411 |
|
|
412 |
chart = cell.get_chart()
|
|
413 |
assert chart.x_labels == ['web', 'mail', 'email']
|
|
414 |
assert chart.raw_series == [([222, 134, 53], {'title': ''})]
|
455 |
415 |
|
|
416 |
# data in X/Y
|
|
417 |
cell.chart_type = 'bar'
|
|
418 |
cell.data_reference = 'plop:third'
|
|
419 |
cell.save()
|
|
420 |
assert cell.cached_json == VISUALIZATION_JSON[2]
|
|
421 |
|
|
422 |
chart = cell.get_chart()
|
|
423 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
424 |
assert chart.raw_series == [
|
|
425 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
426 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
427 |
]
|
|
428 |
|
|
429 |
# single data point
|
|
430 |
cell.chart_type = 'bar'
|
|
431 |
cell.data_reference = 'plop:fourth'
|
|
432 |
cell.save()
|
|
433 |
assert cell.cached_json == VISUALIZATION_JSON[3]
|
|
434 |
|
|
435 |
chart = cell.get_chart()
|
|
436 |
assert chart.x_labels == ['']
|
|
437 |
assert chart.raw_series == [([222], {'title': ''})]
|
|
438 |
|
|
439 |
# loop/X
|
|
440 |
cell.data_reference = 'plop:fifth'
|
|
441 |
cell.save()
|
|
442 |
chart = cell.get_chart()
|
|
443 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
444 |
assert chart.raw_series == [
|
|
445 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
446 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
447 |
]
|
|
448 |
|
|
449 |
# loop/Y
|
|
450 |
cell.data_reference = 'plop:sixth'
|
|
451 |
cell.save()
|
|
452 |
chart = cell.get_chart()
|
|
453 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
454 |
assert chart.raw_series == [
|
|
455 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
456 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
457 |
]
|
|
458 |
|
|
459 |
|
|
460 |
@with_httmock(bijoe_mock)
|
456 |
461 |
def test_chartng_cell_sort_order_alpha(app):
|
457 |
462 |
page = Page(title='One', slug='index')
|
458 |
463 |
page.save()
|
459 |
464 |
|
460 |
|
with override_settings(KNOWN_SERVICES={
|
461 |
|
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
462 |
|
'secret': 'combo', 'orig': 'combo'}}}):
|
463 |
|
with HTTMock(bijoe_mock):
|
464 |
|
cell = ChartNgCell(page=page, order=1)
|
465 |
|
cell.data_reference = 'plop:example'
|
466 |
|
cell.sort_order = 'alpha'
|
467 |
|
cell.save()
|
468 |
|
assert cell.cached_json == VISUALIZATION_JSON[0]
|
469 |
|
|
470 |
|
# bar
|
471 |
|
chart = cell.get_chart()
|
472 |
|
assert chart.__class__.__name__ == 'Bar'
|
473 |
|
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
474 |
|
assert chart.raw_series == [([53, 134, 0, 222], {'title': ''})]
|
475 |
|
|
476 |
|
# horizontal bar
|
477 |
|
cell.chart_type = 'horizontal-bar'
|
478 |
|
chart = cell.get_chart()
|
479 |
|
assert chart.__class__.__name__ == 'HorizontalBar'
|
480 |
|
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
481 |
|
assert chart.raw_series == [([53, 134, 0, 222], {'title': ''})]
|
482 |
|
|
483 |
|
# pie
|
484 |
|
cell.chart_type = 'pie'
|
485 |
|
chart = cell.get_chart()
|
486 |
|
assert chart.__class__.__name__ == 'Pie'
|
487 |
|
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
488 |
|
assert chart.raw_series == [
|
489 |
|
([53], {'title': u'email'}),
|
490 |
|
([134], {'title': u'mail'}),
|
491 |
|
([222], {'title': u'web'})
|
492 |
|
]
|
493 |
|
|
494 |
|
# data in Y
|
495 |
|
cell.chart_type = 'bar'
|
496 |
|
cell.data_reference = 'plop:second'
|
497 |
|
cell.save()
|
498 |
|
assert cell.cached_json == VISUALIZATION_JSON[1]
|
499 |
|
|
500 |
|
chart = cell.get_chart()
|
501 |
|
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
502 |
|
assert chart.raw_series == [([53, 134, 0, 222], {'title': ''})]
|
503 |
|
|
504 |
|
# data in X/Y
|
505 |
|
cell.chart_type = 'bar'
|
506 |
|
cell.data_reference = 'plop:third'
|
507 |
|
cell.save()
|
508 |
|
assert cell.cached_json == VISUALIZATION_JSON[2]
|
509 |
|
|
510 |
|
chart = cell.get_chart()
|
511 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
512 |
|
assert chart.raw_series == [
|
513 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
514 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
515 |
|
]
|
516 |
|
|
517 |
|
# single data point
|
518 |
|
cell.chart_type = 'bar'
|
519 |
|
cell.data_reference = 'plop:fourth'
|
520 |
|
cell.save()
|
521 |
|
assert cell.cached_json == VISUALIZATION_JSON[3]
|
522 |
|
|
523 |
|
chart = cell.get_chart()
|
524 |
|
assert chart.x_labels == ['']
|
525 |
|
assert chart.raw_series == [([222], {'title': ''})]
|
526 |
|
|
527 |
|
# loop/X
|
528 |
|
cell.data_reference = 'plop:fifth'
|
529 |
|
cell.save()
|
530 |
|
chart = cell.get_chart()
|
531 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
532 |
|
assert chart.raw_series == [
|
533 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
534 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
535 |
|
]
|
536 |
|
|
537 |
|
# loop/Y
|
538 |
|
cell.data_reference = 'plop:sixth'
|
539 |
|
cell.save()
|
540 |
|
chart = cell.get_chart()
|
541 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
542 |
|
assert chart.raw_series == [
|
543 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
544 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
545 |
|
]
|
|
465 |
cell = ChartNgCell(page=page, order=1)
|
|
466 |
cell.data_reference = 'plop:example'
|
|
467 |
cell.sort_order = 'alpha'
|
|
468 |
cell.save()
|
|
469 |
assert cell.cached_json == VISUALIZATION_JSON[0]
|
|
470 |
|
|
471 |
# bar
|
|
472 |
chart = cell.get_chart()
|
|
473 |
assert chart.__class__.__name__ == 'Bar'
|
|
474 |
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
|
475 |
assert chart.raw_series == [([53, 134, 0, 222], {'title': ''})]
|
|
476 |
|
|
477 |
# horizontal bar
|
|
478 |
cell.chart_type = 'horizontal-bar'
|
|
479 |
chart = cell.get_chart()
|
|
480 |
assert chart.__class__.__name__ == 'HorizontalBar'
|
|
481 |
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
|
482 |
assert chart.raw_series == [([53, 134, 0, 222], {'title': ''})]
|
|
483 |
|
|
484 |
# pie
|
|
485 |
cell.chart_type = 'pie'
|
|
486 |
chart = cell.get_chart()
|
|
487 |
assert chart.__class__.__name__ == 'Pie'
|
|
488 |
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
|
489 |
assert chart.raw_series == [
|
|
490 |
([53], {'title': u'email'}),
|
|
491 |
([134], {'title': u'mail'}),
|
|
492 |
([222], {'title': u'web'})
|
|
493 |
]
|
|
494 |
|
|
495 |
# data in Y
|
|
496 |
cell.chart_type = 'bar'
|
|
497 |
cell.data_reference = 'plop:second'
|
|
498 |
cell.save()
|
|
499 |
assert cell.cached_json == VISUALIZATION_JSON[1]
|
|
500 |
|
|
501 |
chart = cell.get_chart()
|
|
502 |
assert chart.x_labels == ['email', 'mail', 'phone', 'web']
|
|
503 |
assert chart.raw_series == [([53, 134, 0, 222], {'title': ''})]
|
|
504 |
|
|
505 |
# data in X/Y
|
|
506 |
cell.chart_type = 'bar'
|
|
507 |
cell.data_reference = 'plop:third'
|
|
508 |
cell.save()
|
|
509 |
assert cell.cached_json == VISUALIZATION_JSON[2]
|
|
510 |
|
|
511 |
chart = cell.get_chart()
|
|
512 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
513 |
assert chart.raw_series == [
|
|
514 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
515 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
516 |
]
|
|
517 |
|
|
518 |
# single data point
|
|
519 |
cell.chart_type = 'bar'
|
|
520 |
cell.data_reference = 'plop:fourth'
|
|
521 |
cell.save()
|
|
522 |
assert cell.cached_json == VISUALIZATION_JSON[3]
|
546 |
523 |
|
|
524 |
chart = cell.get_chart()
|
|
525 |
assert chart.x_labels == ['']
|
|
526 |
assert chart.raw_series == [([222], {'title': ''})]
|
547 |
527 |
|
|
528 |
# loop/X
|
|
529 |
cell.data_reference = 'plop:fifth'
|
|
530 |
cell.save()
|
|
531 |
chart = cell.get_chart()
|
|
532 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
533 |
assert chart.raw_series == [
|
|
534 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
535 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
536 |
]
|
|
537 |
|
|
538 |
# loop/Y
|
|
539 |
cell.data_reference = 'plop:sixth'
|
|
540 |
cell.save()
|
|
541 |
chart = cell.get_chart()
|
|
542 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
543 |
assert chart.raw_series == [
|
|
544 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
545 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
546 |
]
|
|
547 |
|
|
548 |
|
|
549 |
@with_httmock(bijoe_mock)
|
548 |
550 |
def test_chartng_cell_sort_order_desc(app):
|
549 |
551 |
page = Page(title='One', slug='index')
|
550 |
552 |
page.save()
|
551 |
553 |
|
552 |
|
with override_settings(KNOWN_SERVICES={
|
553 |
|
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
554 |
|
'secret': 'combo', 'orig': 'combo'}}}):
|
555 |
|
with HTTMock(bijoe_mock):
|
556 |
|
cell = ChartNgCell(page=page, order=1)
|
557 |
|
cell.data_reference = 'plop:example'
|
558 |
|
cell.sort_order = 'desc'
|
559 |
|
cell.save()
|
560 |
|
assert cell.cached_json == VISUALIZATION_JSON[0]
|
561 |
|
|
562 |
|
# bar
|
563 |
|
chart = cell.get_chart()
|
564 |
|
assert chart.__class__.__name__ == 'Bar'
|
565 |
|
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
566 |
|
assert chart.raw_series == [([222, 134, 53, 0], {'title': ''})]
|
567 |
|
|
568 |
|
# horizontal bar
|
569 |
|
cell.chart_type = 'horizontal-bar'
|
570 |
|
chart = cell.get_chart()
|
571 |
|
assert chart.__class__.__name__ == 'HorizontalBar'
|
572 |
|
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
573 |
|
assert chart.raw_series == [([222, 134, 53, 0], {'title': ''})]
|
574 |
|
|
575 |
|
# pie
|
576 |
|
cell.chart_type = 'pie'
|
577 |
|
chart = cell.get_chart()
|
578 |
|
assert chart.__class__.__name__ == 'Pie'
|
579 |
|
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
580 |
|
assert chart.raw_series == [
|
581 |
|
([222], {'title': u'web'}),
|
582 |
|
([134], {'title': u'mail'}),
|
583 |
|
([53], {'title': u'email'})
|
584 |
|
]
|
585 |
|
|
586 |
|
# data in Y
|
587 |
|
cell.chart_type = 'bar'
|
588 |
|
cell.data_reference = 'plop:second'
|
589 |
|
cell.save()
|
590 |
|
assert cell.cached_json == VISUALIZATION_JSON[1]
|
591 |
|
|
592 |
|
chart = cell.get_chart()
|
593 |
|
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
594 |
|
assert chart.raw_series == [([222, 134, 53, 0], {'title': ''})]
|
595 |
|
|
596 |
|
# data in X/Y
|
597 |
|
cell.chart_type = 'bar'
|
598 |
|
cell.data_reference = 'plop:third'
|
599 |
|
cell.save()
|
600 |
|
assert cell.cached_json == VISUALIZATION_JSON[2]
|
601 |
|
|
602 |
|
chart = cell.get_chart()
|
603 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
604 |
|
assert chart.raw_series == [
|
605 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
606 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
607 |
|
]
|
608 |
|
|
609 |
|
# single data point
|
610 |
|
cell.chart_type = 'bar'
|
611 |
|
cell.data_reference = 'plop:fourth'
|
612 |
|
cell.save()
|
613 |
|
assert cell.cached_json == VISUALIZATION_JSON[3]
|
614 |
|
|
615 |
|
chart = cell.get_chart()
|
616 |
|
assert chart.x_labels == ['']
|
617 |
|
assert chart.raw_series == [([222], {'title': ''})]
|
618 |
|
|
619 |
|
# loop/X
|
620 |
|
cell.data_reference = 'plop:fifth'
|
621 |
|
cell.save()
|
622 |
|
chart = cell.get_chart()
|
623 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
624 |
|
assert chart.raw_series == [
|
625 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
626 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
627 |
|
]
|
628 |
|
|
629 |
|
# loop/Y
|
630 |
|
cell.data_reference = 'plop:sixth'
|
631 |
|
cell.save()
|
632 |
|
chart = cell.get_chart()
|
633 |
|
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
634 |
|
assert chart.raw_series == [
|
635 |
|
([222, 134, 0, 53], {'title': u'foo'}),
|
636 |
|
([122, 114, 2, 33], {'title': u'bar'}),
|
637 |
|
]
|
|
554 |
cell = ChartNgCell(page=page, order=1)
|
|
555 |
cell.data_reference = 'plop:example'
|
|
556 |
cell.sort_order = 'desc'
|
|
557 |
cell.save()
|
|
558 |
assert cell.cached_json == VISUALIZATION_JSON[0]
|
|
559 |
|
|
560 |
# bar
|
|
561 |
chart = cell.get_chart()
|
|
562 |
assert chart.__class__.__name__ == 'Bar'
|
|
563 |
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
|
564 |
assert chart.raw_series == [([222, 134, 53, 0], {'title': ''})]
|
|
565 |
|
|
566 |
# horizontal bar
|
|
567 |
cell.chart_type = 'horizontal-bar'
|
|
568 |
chart = cell.get_chart()
|
|
569 |
assert chart.__class__.__name__ == 'HorizontalBar'
|
|
570 |
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
|
571 |
assert chart.raw_series == [([222, 134, 53, 0], {'title': ''})]
|
|
572 |
|
|
573 |
# pie
|
|
574 |
cell.chart_type = 'pie'
|
|
575 |
chart = cell.get_chart()
|
|
576 |
assert chart.__class__.__name__ == 'Pie'
|
|
577 |
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
|
578 |
assert chart.raw_series == [
|
|
579 |
([222], {'title': u'web'}),
|
|
580 |
([134], {'title': u'mail'}),
|
|
581 |
([53], {'title': u'email'})
|
|
582 |
]
|
|
583 |
|
|
584 |
# data in Y
|
|
585 |
cell.chart_type = 'bar'
|
|
586 |
cell.data_reference = 'plop:second'
|
|
587 |
cell.save()
|
|
588 |
assert cell.cached_json == VISUALIZATION_JSON[1]
|
|
589 |
|
|
590 |
chart = cell.get_chart()
|
|
591 |
assert chart.x_labels == ['web', 'mail', 'email', 'phone']
|
|
592 |
assert chart.raw_series == [([222, 134, 53, 0], {'title': ''})]
|
|
593 |
|
|
594 |
# data in X/Y
|
|
595 |
cell.chart_type = 'bar'
|
|
596 |
cell.data_reference = 'plop:third'
|
|
597 |
cell.save()
|
|
598 |
assert cell.cached_json == VISUALIZATION_JSON[2]
|
|
599 |
|
|
600 |
chart = cell.get_chart()
|
|
601 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
602 |
assert chart.raw_series == [
|
|
603 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
604 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
605 |
]
|
|
606 |
|
|
607 |
# single data point
|
|
608 |
cell.chart_type = 'bar'
|
|
609 |
cell.data_reference = 'plop:fourth'
|
|
610 |
cell.save()
|
|
611 |
assert cell.cached_json == VISUALIZATION_JSON[3]
|
|
612 |
|
|
613 |
chart = cell.get_chart()
|
|
614 |
assert chart.x_labels == ['']
|
|
615 |
assert chart.raw_series == [([222], {'title': ''})]
|
|
616 |
|
|
617 |
# loop/X
|
|
618 |
cell.data_reference = 'plop:fifth'
|
|
619 |
cell.save()
|
|
620 |
chart = cell.get_chart()
|
|
621 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
622 |
assert chart.raw_series == [
|
|
623 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
624 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
625 |
]
|
|
626 |
|
|
627 |
# loop/Y
|
|
628 |
cell.data_reference = 'plop:sixth'
|
|
629 |
cell.save()
|
|
630 |
chart = cell.get_chart()
|
|
631 |
assert chart.x_labels == ['web', 'mail', 'phone', 'email']
|
|
632 |
assert chart.raw_series == [
|
|
633 |
([222, 134, 0, 53], {'title': u'foo'}),
|
|
634 |
([122, 114, 2, 33], {'title': u'bar'}),
|
|
635 |
]
|
638 |
636 |
|
639 |
637 |
|
|
638 |
@with_httmock(bijoe_mock)
|
640 |
639 |
def test_chartng_cell_view(app, normal_user):
|
641 |
640 |
page = Page(title='One', slug='index')
|
642 |
641 |
page.save()
|
643 |
642 |
|
644 |
|
with override_settings(KNOWN_SERVICES={
|
645 |
|
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
646 |
|
'secret': 'combo', 'orig': 'combo'}}}):
|
647 |
|
with HTTMock(bijoe_mock):
|
648 |
|
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
649 |
|
cell.data_reference = 'plop:example'
|
650 |
|
cell.save()
|
651 |
|
location = '/api/dataviz/graph/%s/' % cell.id
|
652 |
|
resp = app.get(location) # get data in cache
|
653 |
|
resp = app.get('/')
|
654 |
|
assert 'min-height: 250px' in resp.text
|
655 |
|
assert location in resp.text
|
656 |
|
|
657 |
|
resp = app.get(location + '?width=400')
|
658 |
|
assert resp.content_type == 'image/svg+xml'
|
659 |
|
|
660 |
|
resp = app.get(location + '?width=') # no crash
|
661 |
|
assert resp.content_type == 'image/svg+xml'
|
662 |
|
|
663 |
|
page.public = False
|
664 |
|
page.save()
|
665 |
|
resp = app.get(location + '?width=400', status=403)
|
666 |
|
|
667 |
|
page.public = True
|
668 |
|
page.save()
|
669 |
|
group = Group(name='plop')
|
670 |
|
group.save()
|
671 |
|
cell.public = False
|
672 |
|
cell.groups.set([group])
|
673 |
|
cell.save()
|
674 |
|
resp = app.get(location + '?width=400', status=403)
|
675 |
|
|
676 |
|
app = login(app, username='normal-user', password='normal-user')
|
677 |
|
resp = app.get(location + '?width=400', status=403)
|
678 |
|
|
679 |
|
normal_user.groups.set([group])
|
680 |
|
normal_user.save()
|
681 |
|
resp = app.get(location + '?width=400', status=200)
|
682 |
|
|
683 |
|
# table visualization
|
684 |
|
cell.chart_type = 'table'
|
685 |
|
cell.save()
|
686 |
|
resp = app.get('/')
|
687 |
|
assert '<td>222</td>' in resp.text
|
|
643 |
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
|
644 |
cell.data_reference = 'plop:example'
|
|
645 |
cell.save()
|
|
646 |
location = '/api/dataviz/graph/%s/' % cell.id
|
|
647 |
resp = app.get(location) # get data in cache
|
|
648 |
resp = app.get('/')
|
|
649 |
assert 'min-height: 250px' in resp.text
|
|
650 |
assert location in resp.text
|
688 |
651 |
|
689 |
|
# unsupported dataset
|
690 |
|
cell.data_reference = 'plop:seventh'
|
691 |
|
cell.save()
|
692 |
|
resp = app.get(location) # get data in cache
|
693 |
|
resp = app.get('/')
|
694 |
|
assert 'Unsupported dataset' in resp.text
|
695 |
|
|
696 |
|
cell.chart_type = 'bar'
|
697 |
|
cell.save()
|
698 |
|
resp = app.get(location + '?width=400', status=200)
|
699 |
|
assert 'Unsupported dataset' in resp.text
|
700 |
|
|
701 |
|
# durations
|
702 |
|
cell.data_reference = 'plop:eighth'
|
703 |
|
cell.chart_type = 'table'
|
704 |
|
cell.save()
|
705 |
|
resp = app.get(location) # get data in cache
|
706 |
|
resp = app.get('/')
|
707 |
|
assert '<td>Less than an hour</td>' in resp.text
|
708 |
|
assert '<td>1 day and 10 hours</td>' in resp.text
|
709 |
|
assert '<td>2 hours</td>' in resp.text
|
710 |
|
assert '<td>1 day</td>' in resp.text
|
711 |
|
|
712 |
|
cell.chart_type = 'bar'
|
713 |
|
cell.save()
|
714 |
|
resp = app.get(location + '?width=400', status=200)
|
715 |
|
assert '>Less than an hour<' in resp.text
|
716 |
|
assert '>1 day and 10 hours<' in resp.text
|
717 |
|
assert '>2 hours<' in resp.text
|
718 |
|
assert '>1 day<' in resp.text
|
719 |
|
|
720 |
|
# percents
|
721 |
|
cell.data_reference = 'plop:tenth'
|
722 |
|
cell.chart_type = 'table'
|
723 |
|
cell.save()
|
724 |
|
resp = app.get(location) # get data in cache
|
725 |
|
resp = app.get('/')
|
726 |
|
assert '<td>10.0%</td>' in resp.text
|
727 |
|
|
728 |
|
cell.chart_type = 'bar'
|
729 |
|
cell.save()
|
730 |
|
resp = app.get(location + '?width=400', status=200)
|
731 |
|
assert '>10.0%<' in resp.text
|
732 |
|
|
733 |
|
# deleted visualization
|
734 |
|
cell.data_reference = 'plop:eleventh'
|
735 |
|
cell.save()
|
736 |
|
resp = app.get(location)
|
737 |
|
assert 'not found' in resp.text
|
738 |
|
|
739 |
|
# cell with missing cached_json (probably after import and missing
|
740 |
|
# bijoe visualisation)
|
741 |
|
cell.chart_type = 'table'
|
742 |
|
cell.save()
|
743 |
|
ChartNgCell.objects.filter(id=cell.id).update(cached_json={})
|
744 |
|
resp = app.get('/')
|
745 |
|
assert 'warningnotice' in resp.text
|
|
652 |
resp = app.get(location + '?width=400')
|
|
653 |
assert resp.content_type == 'image/svg+xml'
|
|
654 |
|
|
655 |
resp = app.get(location + '?width=') # no crash
|
|
656 |
assert resp.content_type == 'image/svg+xml'
|
|
657 |
|
|
658 |
page.public = False
|
|
659 |
page.save()
|
|
660 |
resp = app.get(location + '?width=400', status=403)
|
|
661 |
|
|
662 |
page.public = True
|
|
663 |
page.save()
|
|
664 |
group = Group(name='plop')
|
|
665 |
group.save()
|
|
666 |
cell.public = False
|
|
667 |
cell.groups.set([group])
|
|
668 |
cell.save()
|
|
669 |
resp = app.get(location + '?width=400', status=403)
|
|
670 |
|
|
671 |
app = login(app, username='normal-user', password='normal-user')
|
|
672 |
resp = app.get(location + '?width=400', status=403)
|
|
673 |
|
|
674 |
normal_user.groups.set([group])
|
|
675 |
normal_user.save()
|
|
676 |
resp = app.get(location + '?width=400', status=200)
|
746 |
677 |
|
|
678 |
# table visualization
|
|
679 |
cell.chart_type = 'table'
|
|
680 |
cell.save()
|
|
681 |
resp = app.get('/')
|
|
682 |
assert '<td>222</td>' in resp.text
|
|
683 |
|
|
684 |
# unsupported dataset
|
|
685 |
cell.data_reference = 'plop:seventh'
|
|
686 |
cell.save()
|
|
687 |
resp = app.get(location) # get data in cache
|
|
688 |
resp = app.get('/')
|
|
689 |
assert 'Unsupported dataset' in resp.text
|
747 |
690 |
|
|
691 |
cell.chart_type = 'bar'
|
|
692 |
cell.save()
|
|
693 |
resp = app.get(location + '?width=400', status=200)
|
|
694 |
assert 'Unsupported dataset' in resp.text
|
|
695 |
|
|
696 |
# durations
|
|
697 |
cell.data_reference = 'plop:eighth'
|
|
698 |
cell.chart_type = 'table'
|
|
699 |
cell.save()
|
|
700 |
resp = app.get(location) # get data in cache
|
|
701 |
resp = app.get('/')
|
|
702 |
assert '<td>Less than an hour</td>' in resp.text
|
|
703 |
assert '<td>1 day and 10 hours</td>' in resp.text
|
|
704 |
assert '<td>2 hours</td>' in resp.text
|
|
705 |
assert '<td>1 day</td>' in resp.text
|
|
706 |
|
|
707 |
cell.chart_type = 'bar'
|
|
708 |
cell.save()
|
|
709 |
resp = app.get(location + '?width=400', status=200)
|
|
710 |
assert '>Less than an hour<' in resp.text
|
|
711 |
assert '>1 day and 10 hours<' in resp.text
|
|
712 |
assert '>2 hours<' in resp.text
|
|
713 |
assert '>1 day<' in resp.text
|
|
714 |
|
|
715 |
# percents
|
|
716 |
cell.data_reference = 'plop:tenth'
|
|
717 |
cell.chart_type = 'table'
|
|
718 |
cell.save()
|
|
719 |
resp = app.get(location) # get data in cache
|
|
720 |
resp = app.get('/')
|
|
721 |
assert '<td>10.0%</td>' in resp.text
|
|
722 |
|
|
723 |
cell.chart_type = 'bar'
|
|
724 |
cell.save()
|
|
725 |
resp = app.get(location + '?width=400', status=200)
|
|
726 |
assert '>10.0%<' in resp.text
|
|
727 |
|
|
728 |
# deleted visualization
|
|
729 |
cell.data_reference = 'plop:eleventh'
|
|
730 |
cell.save()
|
|
731 |
resp = app.get(location)
|
|
732 |
assert 'not found' in resp.text
|
|
733 |
|
|
734 |
# cell with missing cached_json (probably after import and missing
|
|
735 |
# bijoe visualisation)
|
|
736 |
cell.chart_type = 'table'
|
|
737 |
cell.save()
|
|
738 |
ChartNgCell.objects.filter(id=cell.id).update(cached_json={})
|
|
739 |
resp = app.get('/')
|
|
740 |
assert 'warningnotice' in resp.text
|
|
741 |
|
|
742 |
|
|
743 |
@with_httmock(bijoe_mock)
|
748 |
744 |
def test_chartng_cell_manager(app, admin_user):
|
749 |
745 |
page = Page(title='One', slug='index')
|
750 |
746 |
page.save()
|
751 |
747 |
|
752 |
748 |
app = login(app)
|
753 |
749 |
|
754 |
|
with override_settings(KNOWN_SERVICES={
|
755 |
|
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
756 |
|
'secret': 'combo', 'orig': 'combo'}}}):
|
757 |
|
with HTTMock(bijoe_mock):
|
758 |
|
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
759 |
|
cell.data_reference = 'plop:example'
|
760 |
|
cell.save()
|
761 |
|
resp = app.get('/manage/pages/%s/' % page.id)
|
762 |
|
assert resp.form['cdataviz_chartngcell-%s-data_reference' % cell.id].options == [
|
763 |
|
(u'plop:eighth', False, u'eighth visualization (duration)'),
|
764 |
|
(u'plop:eleventh', False, u'eleventh visualization (not found)'),
|
765 |
|
(u'plop:example', True, u'example visualization (X)'),
|
766 |
|
(u'plop:fifth', False, u'fifth visualization (loop/X)'),
|
767 |
|
(u'plop:fourth', False, u'fourth visualization (no axis)'),
|
768 |
|
(u'plop:nineth', False, u'nineth visualization (loop over varying dimensions)'),
|
769 |
|
(u'plop:second', False, u'second visualization (Y)'),
|
770 |
|
(u'plop:seventh', False, u'seventh visualization (loop/X/Y)'),
|
771 |
|
(u'plop:sixth', False, u'sixth visualization (loop/Y)'),
|
772 |
|
(u'plop:tenth', False, u'tenth visualization (percents)'),
|
773 |
|
(u'plop:third', False, u'third visualization (X/Y)'),
|
774 |
|
]
|
775 |
|
|
776 |
|
|
|
750 |
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
|
751 |
cell.data_reference = 'plop:example'
|
|
752 |
cell.save()
|
|
753 |
resp = app.get('/manage/pages/%s/' % page.id)
|
|
754 |
assert resp.form['cdataviz_chartngcell-%s-data_reference' % cell.id].options == [
|
|
755 |
(u'plop:eighth', False, u'eighth visualization (duration)'),
|
|
756 |
(u'plop:eleventh', False, u'eleventh visualization (not found)'),
|
|
757 |
(u'plop:example', True, u'example visualization (X)'),
|
|
758 |
(u'plop:fifth', False, u'fifth visualization (loop/X)'),
|
|
759 |
(u'plop:fourth', False, u'fourth visualization (no axis)'),
|
|
760 |
(u'plop:nineth', False, u'nineth visualization (loop over varying dimensions)'),
|
|
761 |
(u'plop:second', False, u'second visualization (Y)'),
|
|
762 |
(u'plop:seventh', False, u'seventh visualization (loop/X/Y)'),
|
|
763 |
(u'plop:sixth', False, u'sixth visualization (loop/Y)'),
|
|
764 |
(u'plop:tenth', False, u'tenth visualization (percents)'),
|
|
765 |
(u'plop:third', False, u'third visualization (X/Y)'),
|
|
766 |
]
|
|
767 |
|
|
768 |
|
|
769 |
@with_httmock(bijoe_mock)
|
777 |
770 |
def test_table_cell(app, admin_user):
|
778 |
771 |
page = Page(title='One', slug='index')
|
779 |
772 |
page.save()
|
780 |
773 |
|
781 |
774 |
app = login(app)
|
782 |
775 |
|
783 |
|
with override_settings(KNOWN_SERVICES={
|
784 |
|
'bijoe': {'plop': {'title': 'test', 'url': 'https://bijoe.example.com',
|
785 |
|
'secret': 'combo', 'orig': 'combo'}}}):
|
786 |
|
with HTTMock(bijoe_mock):
|
787 |
|
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
788 |
|
cell.data_reference = 'plop:example'
|
789 |
|
cell.chart_type = 'table'
|
790 |
|
cell.save()
|
791 |
|
location = '/api/dataviz/graph/%s/' % cell.id
|
792 |
|
resp = app.get(location)
|
793 |
|
resp = app.get('/')
|
794 |
|
assert resp.text.count('Total') == 1
|
|
776 |
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
|
777 |
cell.data_reference = 'plop:example'
|
|
778 |
cell.chart_type = 'table'
|
|
779 |
cell.save()
|
|
780 |
location = '/api/dataviz/graph/%s/' % cell.id
|
|
781 |
resp = app.get(location)
|
|
782 |
resp = app.get('/')
|
|
783 |
assert resp.text.count('Total') == 1
|
795 |
784 |
|
796 |
|
cell.data_reference = 'plop:second'
|
797 |
|
cell.save()
|
798 |
|
resp = app.get(location)
|
799 |
|
resp = app.get('/')
|
800 |
|
assert resp.text.count('Total') == 1
|
|
785 |
cell.data_reference = 'plop:second'
|
|
786 |
cell.save()
|
|
787 |
resp = app.get(location)
|
|
788 |
resp = app.get('/')
|
|
789 |
assert resp.text.count('Total') == 1
|
801 |
790 |
|
802 |
|
cell.data_reference = 'plop:third'
|
803 |
|
cell.save()
|
804 |
|
resp = app.get(location)
|
805 |
|
resp = app.get('/')
|
806 |
|
assert '114' in resp.text
|
807 |
|
assert resp.text.count('Total') == 2
|
|
791 |
cell.data_reference = 'plop:third'
|
|
792 |
cell.save()
|
|
793 |
resp = app.get(location)
|
|
794 |
resp = app.get('/')
|
|
795 |
assert '114' in resp.text
|
|
796 |
assert resp.text.count('Total') == 2
|
808 |
797 |
|
809 |
|
cell.data_reference = 'plop:fourth'
|
810 |
|
cell.save()
|
811 |
|
resp = app.get(location)
|
812 |
|
resp = app.get('/')
|
813 |
|
assert resp.text.count('Total') == 0
|
|
798 |
cell.data_reference = 'plop:fourth'
|
|
799 |
cell.save()
|
|
800 |
resp = app.get(location)
|
|
801 |
resp = app.get('/')
|
|
802 |
assert resp.text.count('Total') == 0
|
814 |
803 |
|
815 |
|
# total of durations is not computed
|
816 |
|
cell.data_reference = 'plop:eigth'
|
817 |
|
cell.save()
|
818 |
|
resp = app.get(location)
|
819 |
|
resp = app.get('/')
|
820 |
|
assert resp.text.count('Total') == 0
|
|
804 |
# total of durations is not computed
|
|
805 |
cell.data_reference = 'plop:eigth'
|
|
806 |
cell.save()
|
|
807 |
resp = app.get(location)
|
|
808 |
resp = app.get('/')
|
|
809 |
assert resp.text.count('Total') == 0
|
821 |
|
-
|