'Asserts the number of queries triggered by
`cms.context_processors.cms_settings` and `cms.middleware.page`'

def test_context_current_page(self):

    from django.template import context
    page_template = 'nav_playground.html'
    original_context = {'TEMPLATES': settings.TEMPLATES}
    page = create_page('page', page_template, 'en', published=True)
    page_2 = create_page('page-2', page_template, 'en', published=True, parent=page)
    self.client.get('/en/plain_view/')
    cache.clear()
    menu_pool.clear()
    context._standard_context_processors = None
    with self.settings(**original_context):
        with self.assertNumQueries(FuzzyInt(0, 17)):
            response = self.client.get('/en/plain_view/')
        with self.assertNumQueries(FuzzyInt(0, 1)):
            self.assertFalse(response.context['request'].current_page)
            self.assertFalse(response.context['request']._current_page_cache)
        with self.assertNumQueries(0):
            template = Variable('CMS_TEMPLATE').resolve(response.context)
            self.assertEqual(template, get_cms_setting('TEMPLATES')[0][0])
    cache.clear()
    menu_pool.clear()
    with self.settings(**original_context):
        with self.assertNumQueries(FuzzyInt(13, 26)) as context:
            response = self.client.get('/en/page-2/')
            template = Variable('CMS_TEMPLATE').resolve(response.context)
            self.assertEqual(template, page_template)
            num_queries_page = len(context.captured_queries)
    cache.clear()
    menu_pool.clear()
    page_2.template = 'INHERIT'
    page_2.save()
    page_2.publish('en')
    with self.settings(**original_context):
        with self.assertNumQueries((num_queries_page + 1)):
            response = self.client.get('/en/page-2/')
            template = Variable('CMS_TEMPLATE').resolve(response.context)
            self.assertEqual(template, page_template)
