Exemplo n.º 1
0
 def test_not_in_navigation_num_queries(self):
     """
     Test for issue 521
     
     Build the following tree:
     
         A
         |-B
           |-C
           \-D (not in nav)
     """
     a = create_page('A', 'nav_playground.html', 'en', published=True,
                     in_navigation=True, reverse_id='a')
     b =create_page('B', 'nav_playground.html', 'en', parent=a,
                    published=True, in_navigation=True)
     c = create_page('C', 'nav_playground.html', 'en', parent=b,
                     published=True, in_navigation=True)
     create_page('D', 'nav_playground.html', 'en', parent=self.reload(b),
                 published=True, in_navigation=False)
     with LanguageOverride('en'):
         context = self.get_context(a.get_absolute_url())
         with self.assertNumQueries(4):
             """
             The 4 queries should be:
                 get all pages
                 get all page permissions
                 get all titles
                 set the menu cache key
             """
             # Actually seems to run:
             tpl = Template("{% load menu_tags %}{% show_menu_below_id 'a' 0 100 100 100 %}")
             tpl.render(context)
Exemplo n.º 2
0
 def test_edit_page_other_site_and_language(self):
     """
     Test that a page can edited via the admin when your current site is
     different from the site you are editing and the language isn't available
     for the current site.
     """
     site = Site.objects.create(domain='otherlang', name='otherlang')
     # Change site for this session
     page_data = self.get_new_page_data()
     page_data['site'] = site.pk
     page_data['title'] = 'changed title'
     TESTLANG = settings.CMS_SITE_LANGUAGES[site.pk][0]
     page_data['language'] = TESTLANG
     superuser = self.get_superuser()
     with self.login_user_context(superuser):
         response = self.client.post(URL_CMS_PAGE_ADD, page_data)
         self.assertRedirects(response, URL_CMS_PAGE)
         page = Page.objects.get(title_set__slug=page_data['slug'])
         with LanguageOverride(TESTLANG):
             self.assertEqual(page.get_title(), 'changed title')