Ejemplo n.º 1
0
 def test_people4_broadcast(self):
     # Broadcast to a person
     input = ".@Someone How are you?"
     output2 = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output2,
                      ".<a href='http://twitter.com/Someone' "
                      "class='my-person-css'>@Someone</a> How are you?")
Ejemplo n.º 2
0
 def test_basic1(self):
     output = tweet2html.format_tweet(
         "This is purely plain text, nothing special",
         True, self.css_classes)
     self.assertEqual(output,
                      "This is purely plain text, nothing special"
                      )
Ejemplo n.º 3
0
 def test_url_punctuation3(self):
     input = "A good website http://john-smith.appspot.com!!!"
     output = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output,
                      "A good website "
                      "<a href='http://john-smith.appspot.com' "
                      "class='my-url-css'>http://john-smith.appspot.com</a>"
                      "!!!")
Ejemplo n.º 4
0
 def test_url_redirect(self):
     input = "This should be a Mashable link, not t.co http://t.co/UrhR20m"
     output = tweet2html.format_tweet(input, True, convert_redirects=True)
     self.assertEqual(output, "This should be a Mashable link, not t.co "
                      "<a href='http://mashable.com/2010/12/16/"
                      "interactive-hotmail/'>"
                      "http://mashable.com/2010/12/16/interactive-hotmail/"
                      "</a>")
Ejemplo n.º 5
0
 def test_topic2_multiple(self):
     input = "I also like #gloves, #scarves"
     output1 = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output1,
                      r"I also like <a href='http://twitter.com/search?"
                      "q=%23gloves' class='my-topic-css'>#gloves</a>, "
                      "<a href='http://twitter.com/search?"
                      "q=%23scarves' class='my-topic-css'>#scarves</a>")
Ejemplo n.º 6
0
 def broken_test_url_unicode(self):
     input = u"Unicode URL http://ja.wikipedia.org/wiki/\u56fd boo"
     output = tweet2html.format_tweet(input, 
                                      check_links=True, 
                                      css_classes=self.css_classes)
     self.assertEqual(output, u"Unicode URL "
                      "<a href='http://ja.wikipedia.org/wiki/\\u56fd' "
                      "class='my-url-css'>http://ja.wikipedia.org/"
                      "wiki/\\u56fd</a> boo")
Ejemplo n.º 7
0
 def test_people2_multiple(self):
     # Multiple people
     input = "@Someone Hello from @SomeoneElse"
     output1 = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output1,
                      "<a href='http://twitter.com/Someone' "
                      "class='my-person-css'>@Someone</a> Hello from "
                      "<a href='http://twitter.com/SomeoneElse' "
                      "class='my-person-css'>@SomeoneElse</a>")
Ejemplo n.º 8
0
 def test_url_punctuation1(self):
     input = "@Someone: Visit http://john-smith.appspot.com! #test"
     output = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output,
                      "<a href='http://twitter.com/Someone' "
                      "class='my-person-css'>@Someone</a>: Visit "
                      "<a href='http://john-smith.appspot.com' "
                      "class='my-url-css'>http://john-smith.appspot.com</a>"
                      "! <a href='http://twitter.com/search?"
                      "q=%23test' class='my-topic-css'>#test</a>")
Ejemplo n.º 9
0
 def test_image_notdirectlink(self):
     input = "Image in webpage: http://twitpic.com/3eg7er"
     html, image_list = tweet2html.format_tweet(input, 
                                                check_links=True, 
                                                css_classes=self.css_classes,
                                                return_images=True)
     self.assertEqual(html, "Image in webpage: "
                      "<a href='http://twitpic.com/3eg7er' "
                      "class='my-url-css'>http://twitpic.com/3eg7er</a>")
     self.assertEqual(len(image_list), 0)
Ejemplo n.º 10
0
 def test_people3_punctuation(self):
     # Check punctuation isn't included in person's name
     input = "@Someone Hello from @SomeoneElse, @AnotherPerson"
     output1 = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output1,
                      "<a href='http://twitter.com/Someone' "
                      "class='my-person-css'>@Someone</a> Hello from "
                      "<a href='http://twitter.com/SomeoneElse' "
                      "class='my-person-css'>@SomeoneElse</a>, "
                      "<a href='http://twitter.com/AnotherPerson' "
                      "class='my-person-css'>@AnotherPerson</a>")
Ejemplo n.º 11
0
 def test_image_directlink(self):
     input = "Direct image link: " + \
         "http://js-test.appspot.com/html/images/smalldot.png"
     html, image_list = tweet2html.format_tweet(input, 
                                                check_links=True, 
                                                css_classes=self.css_classes,
                                                return_images=True)
     self.assertEqual(html, "Direct image link: "
                      "<a href='http://js-test.appspot.com/html/"
                      "images/smalldot.png' "
                      "class='my-url-css'>http://js-test.appspot.com/html/"
                      "images/smalldot.png</a>")
     self.assertEqual(len(image_list), 1)
     self.assertEqual(image_list[0], 
                      "http://js-test.appspot.com/html/images/smalldot.png")
Ejemplo n.º 12
0
 def test_url_with_styling(self):
     input = "Visit http://john-smith.appspot.com"
     output = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output,
                      "Visit <a href='http://john-smith.appspot.com' "
                      "class='my-url-css'>http://john-smith.appspot.com</a>")
Ejemplo n.º 13
0
 def test_topic1_without_styling(self):
     input = "I like #umbrellas"
     output2 = tweet2html.format_tweet(input, True, None)
     self.assertEqual(output2,
                      r"I like <a href='http://twitter.com/search?"
                      "q=%23umbrellas'>#umbrellas</a>")
Ejemplo n.º 14
0
 def test_topic1_with_styling(self):
     input = "I like #umbrellas"
     output1 = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output1,
                      r"I like <a href='http://twitter.com/search?"
                      "q=%23umbrellas' class='my-topic-css'>#umbrellas</a>")
Ejemplo n.º 15
0
 def test_people1_without_styling(self):
     input = "@Someone How are you?"
     output2 = tweet2html.format_tweet(input, True, None)
     self.assertEqual(output2,
                      "<a href='http://twitter.com/Someone'>"
                      "@Someone</a> How are you?")
Ejemplo n.º 16
0
 def test_people1_with_styling(self):
     input = "@Someone How are you?"
     output1 = tweet2html.format_tweet(input, True, self.css_classes)
     self.assertEqual(output1,
                      "<a href='http://twitter.com/Someone' "
                      "class='my-person-css'>@Someone</a> How are you?")
Ejemplo n.º 17
0
 def test_url_without_styling(self):
     input = "Visit http://john-smith.appspot.com"
     output = tweet2html.format_tweet(input, True, None)
     self.assertEqual(output,
                      "Visit <a href='http://john-smith.appspot.com'>"
                      "http://john-smith.appspot.com</a>")