Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test to show the query reduction of this branch

for comical relief, let this test run on current develop.

Spoiler: AssertionError: 64 queries executed, 4 expected
  • Loading branch information...
commit dc4dec9d8ff28040051ee2c6fe69da7e52cc34bd 1 parent fe12318
@piquadrat piquadrat authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 cms/tests/page.py
View
22 cms/tests/page.py
@@ -630,6 +630,28 @@ def test_public_home_page_replaced(self):
self.assertEqual(Page.objects.drafts().get_home().get_slug(), 'home')
self.assertEqual(Page.objects.public().get_home().get_slug(), 'home')
+ def test_plugin_loading_queries(self):
+ with SettingsOverride(CMS_TEMPLATES = (('placeholder_tests/base.html', 'tpl'),)):
+ page = create_page('home', 'placeholder_tests/base.html', 'en', published=True, slug='home')
+ placeholders = list(page.placeholders.all())
+ for i, placeholder in enumerate(placeholders):
+ for j in range(5):
+ add_plugin(placeholder, TextPlugin, 'en', body='text-%d-%d' % (i, j))
+ add_plugin(placeholder, LinkPlugin, 'en', name='link-%d-%d' % (i, j))
+ from django.db import connection
+ connection.queries = []
+
+ # trigger the apphook query so that it doesn't get in our way
+ reverse('pages-root')
+ with self.assertNumQueries(4):
+ context = self.get_context()
+ for i, placeholder in enumerate(placeholders):
+ content = get_placeholder_content(context, context['request'], page, placeholder.slot, False)
+ for j in range(5):
+ self.assertIn('text-%d-%d' % (i, j), content)
+ self.assertIn('link-%d-%d' % (i, j), content)
+
+
class NoAdminPageTests(CMSTestCase):
urls = 'cms.test_utils.project.noadmin_urls'
Please sign in to comment.
Something went wrong with that request. Please try again.