From 3b75d3db280d26b390d249a722599238c137ef92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Thu, 12 Mar 2020 11:45:40 +0100 Subject: [PATCH] wcs: test num queries on page display (#40675) --- tests/test_wcs.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_wcs.py b/tests/test_wcs.py index 3c0ae747..0da50ced 100644 --- a/tests/test_wcs.py +++ b/tests/test_wcs.py @@ -16,8 +16,10 @@ from django.apps import apps from django.conf import settings from django.core.cache import cache from django.core.urlresolvers import reverse +from django.db import connection from django.test import override_settings from django.test.client import RequestFactory +from django.test.utils import CaptureQueriesContext from django.utils.six.moves.urllib import parse as urlparse import mock @@ -1209,6 +1211,26 @@ def test_import_export_pages_with_links(): 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 def test_hourly(): appconfig = apps.get_app_config('wcs')