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)' )
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">' )
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>' )
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), '')
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)' )
def test_local_link_not_replaced(self): text = '<a href="/some-link">some link</a>' self.assertEqual(replace_links_with_text(text), text)
def test_link_without_url_replaced(self): text = '<a>some link</a>' self.assertEqual(replace_links_with_text(text), 'some link')
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)')
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">')
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)')