Projet

Général

Profil

0001-wcs-test-num-queries-on-page-display-40675.patch

Lauréline Guérin, 12 mars 2020 11:53

Télécharger (1,71 ko)

Voir les différences:

Subject: [PATCH 1/2] wcs: test num queries on page display (#40675)

 tests/test_wcs.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
tests/test_wcs.py
16 16
from django.conf import settings
17 17
from django.core.cache import cache
18 18
from django.core.urlresolvers import reverse
19
from django.db import connection
19 20
from django.test import override_settings
20 21
from django.test.client import RequestFactory
22
from django.test.utils import CaptureQueriesContext
21 23
from django.utils.six.moves.urllib import parse as urlparse
22 24

  
23 25
import mock
......
1209 1211
    assert new_item.cached_json == item.cached_json
1210 1212

  
1211 1213

  
1214
@wcs_present
1215
def test_view_page_with_wcs_cells_num_queries(app, admin_user):
1216
    page = Page.objects.create(title=u'bar', slug='index', order=1)
1217
    for i in range(0, 15):
1218
        WcsCurrentDraftsCell.objects.create(
1219
            page=page,
1220
            placeholder='content',
1221
            order=i)
1222
    for i in range(15, 50):
1223
        WcsCurrentFormsCell.objects.create(
1224
            page=page,
1225
            placeholder='content',
1226
            order=i)
1227
    app = login(app)
1228
    app.get('/')  # load once to populate caches
1229
    with CaptureQueriesContext(connection) as ctx:
1230
        app.get('/')
1231
        assert len(ctx.captured_queries) == 160
1232

  
1233

  
1212 1234
@wcs_present
1213 1235
def test_hourly():
1214 1236
    appconfig = apps.get_app_config('wcs')
1215
-