示例#1
0
 def test_no_fetch_if_show_preview_false(self, fetch_og, fetch_oembed,
                                         find_urls):
     self.content.show_preview = False
     fetch_content_preview(self.content)
     assert not fetch_og.called
     assert not fetch_oembed.called
     assert not find_urls.called
示例#2
0
def fetch_preview(content):
    try:
        fetch_content_preview(content)
    except Exception as ex:
        logger.exception("Failed to fetch content preview for %s: %s", content,
                         ex)
示例#3
0
 def test_fetch_og_preview_called(self, fetch_og, fetch_oembed, find_urls):
     fetch_content_preview(self.content)
     fetch_og.assert_called_once_with(self.content, ["example.com"])
示例#4
0
def fetch_preview(content):
    try:
        fetch_content_preview(content)
    except Exception as ex:
        logger.exception("Failed to fetch content preview for %s: %s", content, ex)
示例#5
0
 def test_find_urls_in_text_called(self, fetch_og, fetch_oembed, find_urls):
     fetch_content_preview(self.content)
     find_urls.assert_called_once_with(self.content.text)
     self.assertTrue(fetch_oembed.called is False)
     self.assertTrue(fetch_og.called is False)
示例#6
0
def fetch_preview(instance, **kwargs):
    try:
        fetch_content_preview(instance)
    except Exception as ex:
        logger.exception("Failed to fetch content preview for %s: %s",
                         instance, ex)
示例#7
0
 def test_find_urls_in_text_called(self, fetch_og, fetch_oembed, find_urls):
     fetch_content_preview(self.content)
     find_urls.assert_called_once_with(self.content.text)
     fetch_oembed.assert_not_called()
     fetch_og.assert_not_called()
示例#8
0
 def test_no_fetch_if_show_preview_false(self, fetch_og, fetch_oembed, find_urls):
     self.content.show_preview = False
     fetch_content_preview(self.content)
     assert not fetch_og.called
     assert not fetch_oembed.called
     assert not find_urls.called
示例#9
0
 def test_fetch_og_preview_called(self, fetch_og, fetch_oembed, find_urls):
     fetch_content_preview(self.content)
     fetch_og.assert_called_once_with(self.content, ["example.com"])
示例#10
0
 def test_find_urls_in_text_called(self, fetch_og, fetch_oembed, find_urls):
     fetch_content_preview(self.content)
     find_urls.assert_called_once_with(self.content.text)
     self.assertTrue(fetch_oembed.called is False)
     self.assertTrue(fetch_og.called is False)