Example #1
0
 def test_hotlinked_image_with_alt_replaced(self):
     text = '<img src="https://example.com/some-image.gif" alt="picture"/>'
     self.assertEqual(
         replace_links_with_text(text),
         'https://example.com/some-image.gif (picture)'
     )
Example #2
0
 def test_local_image_not_replaced(self):
     text = u'<img src="/some-image.gif"/>'
     self.assertEqual(
             replace_links_with_text(text), 
             u'<img src="/some-image.gif">'
         )
Example #3
0
 def test_local_url_with_hotlinked_image_replaced(self):
     text = '<a href="/some-link"><img src="http://example.com/img.png" alt="picture""> some text</a>'
     self.assertEqual(
         replace_links_with_text(text),
         '<a href="/some-link">http://example.com/img.png (picture) some text</a>'
     )
Example #4
0
 def test_external_link_without_text_replaced(self):
     text = '<a href="https://example.com/"></a>'
     #in this case we delete the link
     self.assertEqual(replace_links_with_text(text), '')
Example #5
0
 def test_external_link_with_text_replaced(self):
     text = '<a href="https://example.com/">some link</a>'
     self.assertEqual(
         replace_links_with_text(text),
         'https://example.com/ (some link)'
     )
Example #6
0
 def test_local_link_not_replaced(self):
     text = '<a href="/some-link">some link</a>'
     self.assertEqual(replace_links_with_text(text), text)
Example #7
0
 def test_link_without_url_replaced(self):
     text = '<a>some link</a>'
     self.assertEqual(replace_links_with_text(text), 'some link')
Example #8
0
 def test_local_url_with_hotlinked_image_replaced(self):
     text = '<a href="/some-link"><img src="http://example.com/img.png" alt="picture""> some text</a>'
     self.assertEqual(
         replace_links_with_text(text),
         '<a href="/some-link">http://example.com/img.png (picture) some text</a>'
     )
Example #9
0
 def test_hotlinked_image_with_alt_replaced(self):
     text = '<img src="https://example.com/some-image.gif" alt="picture"/>'
     self.assertEqual(replace_links_with_text(text),
                      'https://example.com/some-image.gif (picture)')
Example #10
0
 def test_local_image_not_replaced(self):
     text = u'<img src="/some-image.gif"/>'
     self.assertEqual(replace_links_with_text(text),
                      u'<img src="/some-image.gif">')
Example #11
0
 def test_external_link_with_text_replaced(self):
     text = '<a href="https://example.com/">some link</a>'
     self.assertEqual(replace_links_with_text(text),
                      'https://example.com/ (some link)')
Example #12
0
 def test_external_link_without_text_replaced(self):
     text = '<a href="https://example.com/"></a>'
     #in this case we delete the link
     self.assertEqual(replace_links_with_text(text), '')
Example #13
0
 def test_link_without_url_replaced(self):
     text = '<a>some link</a>'
     self.assertEqual(replace_links_with_text(text), 'some link')
Example #14
0
 def test_local_link_not_replaced(self):
     text = '<a href="/some-link">some link</a>'
     self.assertEqual(replace_links_with_text(text), text)