Exemple #1
0
 def test_placeholder_cache_bug(self):
     """There was an bad bug caused when the page cache was filled
     the first time."""
     from basic_cms.placeholders import PlaceholderNode
     page = self.new_page()
     placeholder = PlaceholderNode('test', page=page)
     placeholder.save(page, 'fr-ch', 'fr', True)
     placeholder.save(page, 'en-us', 'en', True)
     self.assertEqual(Content.objects.get_content(page, 'fr-ch', 'test'),
                      'fr')
 def test_placeholder_cache_bug(self):
     """There was an bad bug caused when the page cache was filled
     the first time."""
     from basic_cms.placeholders import PlaceholderNode
     page = self.new_page()
     placeholder = PlaceholderNode('test', page=page)
     placeholder.save(page, 'fr-ch', 'fr', True)
     placeholder.save(page, 'en-us', 'en', True)
     self.assertEqual(
         Content.objects.get_content(page, 'fr-ch', 'test'),
         'fr'
     )
    def test_placeholder_untranslated_content(self):
        """Test placeholder untranslated content."""
        self.set_setting("PAGE_USE_SITE_ID", False)
        page = self.new_page(content={})
        placeholder = PlaceholderNode('untrans', page='p', untranslated=True)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        placeholder.save(page, 'en-us', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 1)
        self.assertEqual(Content.objects.all()[0].language, 'en-us')

        placeholder = PlaceholderNode('untrans', page='p', untranslated=False)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 2)

        # test the syntax
        page = self.new_page()
        template = django.template.loader.get_template(
            'pages/tests/untranslated.html')
        context = Context({'current_page': page, 'lang': 'en-us'})
        self.assertEqual(template.render(context), '')
    def test_placeholder_untranslated_content(self):
        """Test placeholder untranslated content."""
        self.set_setting("PAGE_USE_SITE_ID", False)
        page = self.new_page(content={})
        placeholder = PlaceholderNode('untrans', page='p', untranslated=True)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        placeholder.save(page, 'en-us', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 1)
        self.assertEqual(Content.objects.all()[0].language, 'en-us')

        placeholder = PlaceholderNode('untrans', page='p', untranslated=False)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 2)

        # test the syntax
        page = self.new_page()
        template = django.template.loader.get_template(
                'pages/tests/untranslated.html')
        context = Context({'current_page': page, 'lang': 'en-us'})
        self.assertEqual(template.render(context), '')