Пример #1
0
    def check_template_meta_image_url(self, expected_root):
        """Template meta tags should use an absolute image URL."""
        image_file = get_test_image_file(filename='foo.png')
        image = mommy.make(CFGOVImage, file=image_file)
        page = LearnPage(social_sharing_image=image)
        response = page.serve(page.dummy_request())
        response.render()

        rendition_url = image.get_rendition('original').url

        self.assertContains(response,
                            ('<meta property="og:image" content='
                             '"{}{}">'.format(expected_root, rendition_url)),
                            html=True)
Пример #2
0
    def test_template_meta_image_no_images(self):
        """Template meta tags should fallback to standard social networks."""
        page = LearnPage(social_sharing_image=None)
        response = page.serve(page.dummy_request())
        response.render()

        self.assertContains(
            response,
            ('<meta property="og:image" content='
             '"http://localhost/static/img/logo_open-graph_facebook.png">'),
            html=True)

        self.assertContains(
            response,
            ('<meta property="twitter:image" content='
             '"http://localhost/static/img/logo_open-graph_twitter.png">'),
            html=True)
Пример #3
0
    def check_template_meta_image_url(self, expected_root):
        """Template meta tags should use an absolute image URL."""
        image_file = get_test_image_file(filename='foo.png')
        image = mommy.make(CFGOVImage, file=image_file)
        page = LearnPage(social_sharing_image=image)
        response = page.serve(page.dummy_request())
        response.render()

        rendition_url = image.get_rendition('original').url

        self.assertContains(
            response,
            (
                '<meta property="og:image" content='
                '"{}{}">'.format(expected_root, rendition_url)
            ),
            html=True
        )
Пример #4
0
    def test_template_meta_image_no_images(self):
        """Template meta tags should fallback to standard social networks."""
        page = LearnPage(social_sharing_image=None)
        response = page.serve(page.dummy_request())
        response.render()

        self.assertContains(
            response,
            (
                '<meta property="og:image" content='
                '"http://localhost/static/img/logo_open-graph_facebook.png">'
            ),
            html=True
        )

        self.assertContains(
            response,
            (
                '<meta property="twitter:image" content='
                '"http://localhost/static/img/logo_open-graph_twitter.png">'
            ),
            html=True
        )