Exemplo n.º 1
0
    def test_should_create_meta_ogurl_on_article_when_it_has_og_url(self):
        self.article.meta_og_url = 'http://mycustomdomain/should-be-article-url.html'

        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['og_url'],
                         'http://mycustomdomain/should-be-article-url.html')
Exemplo n.º 2
0
    def test_should_create_meta_ogimage_on_article_when_it_has_og_image(self):
        self.article.meta_og_image = 'http://mycustomdomain/og.jpg'

        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['og_image'],
                         'http://mycustomdomain/og.jpg')
Exemplo n.º 3
0
    def test_should_limit_the_summary_content_when_using_it_as_description(self):
        self.article.summary = """<p>Do you see any "Teletubbies" in here? Do you
        see a slender plastic tag clipped to my shirt with my name printed on
        it? Do you see a little Asian child with a blank expression on his
        face sitting outside on a mechanical helicopter that shakes when you
        put quarters in it? No? Well, that's what you see at a toy store.
        And you must think you're in a toy store, because you're here shopping
        for an infant named Jeb.<p>"""
        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['description'],
            'Do you see any &#34;Teletubbies&#34; in here? Do you see a slender plastic tag clipped to my shirt with my name printed on it? Do you see a little Asian child with...')
Exemplo n.º 4
0
    def test_should_create_meta_ogdescription_on_article_when_it_has_og_description(self):
        self.article.meta_og_description = 'should-be-meta-og-description'

        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['og_description'], 'should-be-meta-og-description')
Exemplo n.º 5
0
    def test_should_create_meta_ogtitle_on_article_when_it_has_og_title(self):
        self.article.meta_og_title = 'should-be-meta-og-title'

        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['og_title'], 'should-be-meta-og-title')
Exemplo n.º 6
0
    def test_should_create_meta_canonical(self):
        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['canonical'],
                            'http://localhost/should-be-the-article-url.html')
Exemplo n.º 7
0
    def test_should_create_meta_robots_on_article_when_it_has_robots(self):
        self.article.meta_robots = 'index,follow'

        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['robots'], 'index,follow')
Exemplo n.º 8
0
    def test_should_create_meta_attribute_on_article_when_it_has_keywords(self):
        self.article.meta_keywords = 'should-be-meta-keywords'

        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['keywords'], 'should-be-meta-keywords')
Exemplo n.º 9
0
    def test_should_create_meta_attribute_with_data_on_articles(self):
        BetterMeta.add_meta_to_articles(self.generator)

        for article in self.generator.articles:
            self.assertEqual(article.meta['description'], 'should-be-description')
Exemplo n.º 10
0
    def test_should_use_the_default_image_as_ogimage_when_article_hasnt_one(self):
        self.article.content = '<p>Lorem ipsum</p>'
        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['og_image'],
                         'should-be-default-og-image.jpg')
Exemplo n.º 11
0
    def test_should_use_the_first_image_of_the_article(self):
        self.article.content = """<h1>hey!</h1><p><div><img src="1.jpg"></div>
        </p><br><img src="2.jpg">"""
        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['og_image'], '1.jpg')
Exemplo n.º 12
0
 def setUp(self):
     super(BetterMetaUnfilledOGMetaTestCase, self).setUp()
     BetterMeta.create_meta_attribute(self.article)
Exemplo n.º 13
0
    def test_should_format_the_summary_to_use_as_description(self):
        self.article.summary = '<p>This is a "test"! <strong>Just a test!</strong></p>'
        BetterMeta.create_meta_attribute(self.article)

        self.assertEqual(self.article.meta['description'], 'This is a &#34;test&#34;! Just a test!')