wcs: test num queries on page display (#40675)

This commit is contained in:
Lauréline Guérin 2020-03-12 11:45:40 +01:00
parent 95d761ebcf
commit 3b75d3db28
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
1 changed files with 22 additions and 0 deletions

View File

@ -16,8 +16,10 @@ from django.apps import apps
from django.conf import settings from django.conf import settings
from django.core.cache import cache from django.core.cache import cache
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db import connection
from django.test import override_settings from django.test import override_settings
from django.test.client import RequestFactory from django.test.client import RequestFactory
from django.test.utils import CaptureQueriesContext
from django.utils.six.moves.urllib import parse as urlparse from django.utils.six.moves.urllib import parse as urlparse
import mock import mock
@ -1209,6 +1211,26 @@ def test_import_export_pages_with_links():
assert new_item.cached_json == item.cached_json assert new_item.cached_json == item.cached_json
@wcs_present
def test_view_page_with_wcs_cells_num_queries(app, admin_user):
page = Page.objects.create(title=u'bar', slug='index', order=1)
for i in range(0, 15):
WcsCurrentDraftsCell.objects.create(
page=page,
placeholder='content',
order=i)
for i in range(15, 50):
WcsCurrentFormsCell.objects.create(
page=page,
placeholder='content',
order=i)
app = login(app)
app.get('/') # load once to populate caches
with CaptureQueriesContext(connection) as ctx:
app.get('/')
assert len(ctx.captured_queries) == 160
@wcs_present @wcs_present
def test_hourly(): def test_hourly():
appconfig = apps.get_app_config('wcs') appconfig = apps.get_app_config('wcs')