Exemplo n.º 1
0
    def test_formatDisplayURLRetweeted(self):
        """
        Retweets with links are rendered properly.
        """
        self.status.user.id = 1
        self.status.user.screen_name = u'test'
        status = self.status.retweeted_status = Status()
        status.text = (u'Today, many XMPP servers switch to mandatory '
                         u'encryption. Happy Open Discussion Day! '
                         u'http://t.co/MNH87vwe4T http://t.co/DbKFDlV9M8')

        user = User()
        user.id = 2426271
        user.screen_name = u'ralphm'
        status.user = user

        status.entities = Entities()

        urls = []

        url = URL()
        url.url = "http://t.co/MNH87vwe4T"
        url.display_url = "opendiscussionday.org"
        url.indices = Indices()
        url.indices.start = 84
        url.indices.end = 106
        urls.append(url)

        url = URL()
        url.url = "http://t.co/DbKFDlV9M8"
        url.display_url = u"stpeter.im/journal/1496.h\u2026"
        url.indices = Indices()
        url.indices.start = 107
        url.indices.end = 129
        urls.append(url)

        status.entities.urls = urls

        notification = self.source.format(self.status)
        self.assertEquals(u'RT @ralphm: '
                            u'Today, many XMPP servers switch to mandatory '
                            u'encryption. Happy Open Discussion Day! '
                            u'opendiscussionday.org '
                            u'stpeter.im/journal/1496.h\u2026',
                          notification['subtitle'])
        self.assertEquals(u'RT @ralphm: '
                            u'Today, many XMPP servers switch to mandatory '
                            u'encryption. Happy Open Discussion Day! '
                            u"<a href='http://t.co/MNH87vwe4T'>"
                              u'opendiscussionday.org</a> '
                            u"<a href='http://t.co/DbKFDlV9M8'>"
                              u'stpeter.im/journal/1496.h\u2026</a>',
                          notification['html'])
Exemplo n.º 2
0
    def setUp(self):
        self.feed = aggregator.Feed(handle=u'test', language=u'en')

        self.source = source.TwitterSource()
        self.source.feed = self.feed
        self.source.activate()

        user = User()
        user.id = 2426271
        user.screen_name = u'ralphm'
        user.profile_image_url = u'http://a2.twimg.com/profile_images/45293402/ralphm-buddy_normal.png'

        self.status = Status()
        self.status.id = 1
        self.status.user = user
        self.status.text = u'Test'

        self.source = source.TwitterSource()
        self.source.feed = self.feed
        self.source.activate()