Example #1
0
 def test_renders_without_previews_with_show_preview_false(self):
     content = Content.objects.create(
         text="foobar", guid="barfoo", author=ProfileFactory(),
         oembed=OEmbedCacheFactory(), opengraph=OpenGraphCacheFactory(),
         show_preview=False,
     )
     self.assertEqual(content.rendered, "<p>foobar</p>")
Example #2
0
 def test_renders_with_oembed(self):
     content = Content.objects.create(text="foobar",
                                      guid="barfoo",
                                      author=ProfileFactory(),
                                      oembed=OEmbedCacheFactory())
     self.assertEqual(content.rendered,
                      "<p>foobar</p><br>%s" % content.oembed.oembed)
Example #3
0
 def test_renders_without_previews_with_show_preview_false(self):
     content = ContentFactory(
         text="foobar",
         oembed=OEmbedCacheFactory(),
         opengraph=OpenGraphCacheFactory(),
         show_preview=False,
     )
     self.assertEqual(content.rendered, "<p>foobar</p>")
Example #4
0
 def test_renders_with_oembed(self):
     content = ContentFactory(text="foobar", oembed=OEmbedCacheFactory())
     self.assertEqual(content.rendered,
                      "<p>foobar</p><br>%s" % content.oembed.oembed)
Example #5
0
 def test_integrityerror_updates_with_found_cache(self, embed, filter):
     oembed = OEmbedCacheFactory(url=self.urls[0])
     result = fetch_oembed_preview(self.content, self.urls)
     self.assertEqual(result, oembed)
Example #6
0
 def test_cache_updated_if_previous_found_older_than_7_days(self, embed):
     with freeze_time(datetime.date.today() - datetime.timedelta(days=8)):
         OEmbedCacheFactory(url=self.urls[0])
     fetch_oembed_preview(self.content, self.urls)
     embed.assert_called_once_with(self.urls[0])
Example #7
0
 def test_cache_not_updated_if_previous_found(self):
     OEmbedCacheFactory(url=self.urls[0])
     result = fetch_oembed_preview(self.content, self.urls)
     self.content.refresh_from_db()
     self.assertEqual(self.content.oembed, result)