Projet

Général

Profil

0001-tests-count-dataviz-queries-50891.patch

Valentin Deniaud, 11 février 2021 14:59

Télécharger (1,78 ko)

Voir les différences:

Subject: [PATCH 1/3] tests: count dataviz queries (#50891)

 tests/test_dataviz.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tests/test_dataviz.py
12 12
from django.db import connection
13 13
from django.db.migrations.executor import MigrationExecutor
14 14
from django.test import override_settings
15
from django.test.utils import CaptureQueriesContext
15 16
from django.utils import timezone
16 17

  
17 18
from combo.data.models import Page, ValidityInfo
......
1040 1041
    assert 'time_interval' in resp.text
1041 1042

  
1042 1043

  
1044
def test_chartng_cell_manager_multiple_cells(app, admin_user, new_api_statistics, nocache):
1045
    page = Page.objects.create(title='One', slug='index')
1046
    cell = ChartNgCell.objects.create(page=page, order=1, placeholder='content')
1047

  
1048
    app = login(app)
1049
    with CaptureQueriesContext(connection) as ctx:
1050
        resp = app.get('/manage/pages/%s/' % page.id)
1051
        assert len(ctx.captured_queries) == 18
1052

  
1053
    cell = ChartNgCell.objects.create(page=page, order=2, placeholder='content')
1054
    cell = ChartNgCell.objects.create(page=page, order=3, placeholder='content')
1055
    with CaptureQueriesContext(connection) as ctx:
1056
        resp = app.get('/manage/pages/%s/' % page.id)
1057
        assert len(ctx.captured_queries) == 20
1058

  
1059

  
1043 1060
@with_httmock(bijoe_mock)
1044 1061
def test_table_cell(app, admin_user, statistics):
1045 1062
    page = Page(title='One', slug='index')
1046
-