Example #1
0
 def test_add_links_to_text_ends(self):
     text = "@foo hi @bar"
     links = [{"start":8, "end":12, "url":"www.bar.com"},
             {"start":0, "end":4, "url":"www.foo.com"}]
     twemail = Twemail()
     text_with_links = twemail._add_links_to_text(text, links)
     self.assertEqual(text_with_links, "<a href=\"www.foo.com\">@foo</a> hi <a href=\"www.bar.com\">@bar</a>")
Example #2
0
 def test_add_links_to_text_none(self):
     text = "@foo hi @bar"
     links = []
     twemail = Twemail()
     text_with_links = twemail._add_links_to_text(text, links)
     self.assertEqual(text_with_links, text)
Example #3
0
 def test_add_links_to_text(self):
     text = "hello @foo goodbye"
     links = [{"start":6, "end":10, "url":"www.foo.com"}]
     twemail = Twemail()
     text_with_links = twemail._add_links_to_text(text, links)
     self.assertEqual(text_with_links, "hello <a href=\"www.foo.com\">@foo</a> goodbye")