コード例 #1
0
ファイル: test_utils.py プロジェクト: takumab/socialhome
 def test_urls_in_text(self):
     urls = find_urls_in_text(self.urls_in_text)
     self.assertEqual(
         urls, {
             "https://example1.com", "https://example2.com",
             "https://example-3.com"
         })
コード例 #2
0
ファイル: previews.py プロジェクト: subkrish/socialhome
def fetch_content_preview(content):
    """Fetch a preview or oEmbed for a content.

    Will first try to fetch oEmbed for each found url.
    If not available, generate a preview from the OG tags.
    """
    urls = find_urls_in_text(content.text)
    if not urls:
        return
    preview_done = fetch_oembed_preview(content, urls)
    if not preview_done:
        fetch_og_preview(content, urls)
コード例 #3
0
ファイル: previews.py プロジェクト: jaywink/socialhome
def fetch_content_preview(content):
    """Fetch a preview or oEmbed for a content.

    Will first try to fetch oEmbed for each found url.
    If not available, generate a preview from the OG tags.
    """
    if not content.show_preview:
        return
    urls = find_urls_in_text(content.text)
    if not urls:
        return
    preview_done = fetch_oembed_preview(content, urls)
    if not preview_done:
        fetch_og_preview(content, urls)
コード例 #4
0
 def test_special_chars(self):
     urls = find_urls_in_text(self.special_chars)
     self.assertEqual(urls, [self.special_chars])
コード例 #5
0
ファイル: test_utils.py プロジェクト: jaywink/socialhome
 def test_without_protocol(self):
     urls = find_urls_in_text(self.without_protocol)
     self.assertEqual(urls, ["http://example.org"])
コード例 #6
0
 def test_starts_with_url(self):
     urls = find_urls_in_text(self.starts_with_url)
     self.assertEqual(urls, [self.starts_with_url])
     urls = find_urls_in_text(self.http_starts_with_url)
     self.assertEqual(urls, [self.http_starts_with_url])
コード例 #7
0
 def test_numbers(self):
     urls = find_urls_in_text(self.numbers)
     self.assertEqual(urls, [self.numbers])
コード例 #8
0
 def test_ignores_mention(self):
     urls = find_urls_in_text(self.with_mention)
     self.assertEqual(urls, ["https://example.net"])
コード例 #9
0
 def test_returns_in_order_without_duplicates(self):
     urls = find_urls_in_text(self.many_for_ordered)
     self.assertEqual(urls, ["http://spam.com", "http://eggs.com"])
コード例 #10
0
 def test_href_markdown(self):
     urls = find_urls_in_text(self.href_and_markdown)
     self.assertEqual(urls, [
         "https://example.com", "https://example.net", "https://example.org"
     ])
コード例 #11
0
 def test_without_protocol(self):
     urls = find_urls_in_text(self.without_protocol)
     self.assertEqual(urls, ["http://example.org"])
コード例 #12
0
ファイル: test_utils.py プロジェクト: jaywink/socialhome
 def test_href_markdown(self):
     urls = find_urls_in_text(self.href_and_markdown)
     self.assertEqual(urls, ["https://example.com", "https://example.net", "https://example.org"])
コード例 #13
0
ファイル: test_utils.py プロジェクト: qincpp/socialhome
 def test_href_markdown_etc_skipped(self):
     urls = find_urls_in_text(self.href_and_markdown)
     self.assertEqual(urls, [])
コード例 #14
0
ファイル: test_utils.py プロジェクト: jaywink/socialhome
 def test_urls_in_text(self):
     urls = find_urls_in_text(self.urls_in_text)
     self.assertEqual(urls, [
         "https://example1.com", "https://example2.com", "https://example-3.com"
     ])
コード例 #15
0
ファイル: test_utils.py プロジェクト: jaywink/socialhome
 def test_special_chars(self):
     urls = find_urls_in_text(self.special_chars)
     self.assertEqual(urls, [self.special_chars])
コード例 #16
0
ファイル: test_utils.py プロジェクト: jaywink/socialhome
 def test_numbers(self):
     urls = find_urls_in_text(self.numbers)
     self.assertEqual(urls, [self.numbers])
コード例 #17
0
ファイル: test_utils.py プロジェクト: jaywink/socialhome
 def test_starts_with_url(self):
     urls = find_urls_in_text(self.starts_with_url)
     self.assertEqual(urls, [self.starts_with_url])
     urls = find_urls_in_text(self.http_starts_with_url)
     self.assertEqual(urls, [self.http_starts_with_url])
コード例 #18
0
ファイル: test_utils.py プロジェクト: jaywink/socialhome
 def test_returns_in_order_without_duplicates(self):
     urls = find_urls_in_text(self.many_for_ordered)
     self.assertEqual(urls, ["http://spam.com", "http://eggs.com"])