Example #1
0
    def test_formatDisplayURL(self):
        self.status.text = (u'#Photos on Twitter: taking flight '
                            'http://t.co/qbJx26r http://t.co/123456')

        self.status.entities = Entities()
        media = Media()
        media.url = "http://t.co/qbJx26r"
        media.display_url = "pic.twitter.com/qbJx26r"
        media.indices = Indices()
        media.indices.start = 34
        media.indices.end = 53
        self.status.entities.media = [media]
        url = URL()
        url.url = "http://t.co/123456"
        url.display_url = u"pic.twitter.com/12345\u2026"
        url.indices = Indices()
        url.indices.start = 54
        url.indices.end = 73
        self.status.entities.urls = [url]

        notification = self.source.format(self.status)
        self.assertEquals(u'#Photos on Twitter: taking flight '
                            u'pic.twitter.com/qbJx26r '
                            u'pic.twitter.com/12345\u2026',
                          notification['subtitle'])
        self.assertEquals(u'#Photos on Twitter: taking flight '
                            u"<a href='http://t.co/qbJx26r'>"
                              u"pic.twitter.com/qbJx26r</a> "
                            u"<a href='http://t.co/123456'>"
                              u"pic.twitter.com/12345\u2026</a>",
                          notification['html'])
Example #2
0
    def test_augmentStatusWithImageMediaEntities(self):
        def cb(entry):
            self.assertEqual(media.media_url, entry.image_url)

        media = Media()
        media.media_url = 'http://p.twimg.com/AQ9JtQsCEAA7dEN.jpg'
        status = Status()
        status.entities = Entities()
        status.entities.media = [media]

        d = self.embedder.augmentStatusWithImage(status)
        d.addCallback(cb)
        return d