Exemple #1
0
 def test_helpers_create_i18n_page_published_not(self, mock_publish):
     """
     Check that `create_i18n_page` does not publish the created page if it is not requested.
     Don't mock `create_page` so we can easily check the call to publish.
     """
     create_i18n_page("my title")
     self.assertFalse(mock_publish.called)
Exemple #2
0
 def test_helpers_create_i18n_page_homepage(self, mock_homepage):
     """
     Check that `create_i18n_page` can set the created page as homepage
     Don't mock `create_page` so we can easily check the call to set it as homepage
     """
     create_i18n_page("my title", is_homepage=True)
     self.assertTrue(mock_homepage.called)
Exemple #3
0
    def test_pages_i18n_hreflang(self):
        """
        The hreflang links should be configured to avoid duplicate content accross languages.
        """
        content = {"fr-ca": "Un, deux", "es": "uno, dos"}
        create_i18n_page(
            content,
            published=True,
            template="richie/single_column.html",
        )
        page = Page.objects.get(publisher_is_draft=False)

        # ... and make sure the hreflinks are on the page in all languages
        for language in ["fr-ca", "es"]:
            response = self.client.get(page.get_absolute_url(language))
            self.assertEqual(200, response.status_code)
            self.assertIn(
                ('<link rel="alternate" href="http://example.com/fr-ca/un-deux/" '
                 'hreflang="fr-ca" />'),
                response.rendered_content,
            )
            self.assertIn(
                '<link rel="alternate" href="http://example.com/es/uno-dos/" hreflang="es" />',
                response.rendered_content,
            )
Exemple #4
0
 def test_helpers_create_i18n_page_published(self, mock_publish):
     """
     Check that `create_i18n_page` publishes the created page in all languages when requested.
     Don't mock `create_page` so we can easily check the call to publish.
     """
     create_i18n_page("my title", published=True, languages=["en", "fr"])
     self.assertEqual([c[0][0] for c in mock_publish.call_args_list],
                      ["en", "fr"])
Exemple #5
0
 def test_helpers_create_i18n_page_homepage_not(self, mock_homepage):
     """
     Check that `create_i18n_page` does not set the created page as homepage if it is not
     requested.
     Don't mock `create_page` so we can easily check the call to set it as homepage
     """
     create_i18n_page("my title")
     self.assertFalse(mock_homepage.called)