From ebc96fcf2844279d0b4a303e20c2f56f294801fe Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 10 Feb 2021 17:49:29 +0100 Subject: [PATCH 1/3] tests: count dataviz queries (#50891) --- tests/test_dataviz.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py index 4c4f5a77..ab1519c8 100644 --- a/tests/test_dataviz.py +++ b/tests/test_dataviz.py @@ -12,6 +12,7 @@ from django.contrib.auth.models import User, Group from django.db import connection from django.db.migrations.executor import MigrationExecutor from django.test import override_settings +from django.test.utils import CaptureQueriesContext from django.utils import timezone from combo.data.models import Page, ValidityInfo @@ -1040,6 +1041,22 @@ def test_chartng_cell_manager_new_api_dynamic_fields(app, admin_user, new_api_st assert 'time_interval' in resp.text +def test_chartng_cell_manager_multiple_cells(app, admin_user, new_api_statistics, nocache): + page = Page.objects.create(title='One', slug='index') + cell = ChartNgCell.objects.create(page=page, order=1, placeholder='content') + + app = login(app) + with CaptureQueriesContext(connection) as ctx: + resp = app.get('/manage/pages/%s/' % page.id) + assert len(ctx.captured_queries) == 18 + + cell = ChartNgCell.objects.create(page=page, order=2, placeholder='content') + cell = ChartNgCell.objects.create(page=page, order=3, placeholder='content') + with CaptureQueriesContext(connection) as ctx: + resp = app.get('/manage/pages/%s/' % page.id) + assert len(ctx.captured_queries) == 20 + + @with_httmock(bijoe_mock) def test_table_cell(app, admin_user, statistics): page = Page(title='One', slug='index') -- 2.20.1