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
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)
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"])
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)
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)
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)
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()
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
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"])
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)