Ejemplo n.º 1
0
    def test_tweet_should_have_created_at_time_when_create_it_from_weibo_html_fragment(self):
        ele = html.fromstring(weibo_sms_html_frag)
        t = Tweet.create_from_weibo_html_fragment(ele)
        created_at = datetime(2010, 11, 10, 11, 19)
        self.assertEquals(created_at.strftime('%Y%m%d %H%M%S'), t.created_at.strftime('%Y%m%d %H%M%S'))

        m = weibo_sms_html_frag.replace(u'11月10日 11:19', '2009-8-29 16:55')
        ele = html.fromstring(m)
        t = Tweet.create_from_weibo_html_fragment(ele)
        created_at = datetime(2009, 8, 29, 16, 55)
        self.assertEquals(created_at.strftime('%Y%m%d %H%M%S'), t.created_at.strftime('%Y%m%d %H%M%S'))
        
        m = weibo_sms_html_frag.replace(u'11月10日 11:19', u'18分钟前')
        ele = html.fromstring(m)
        t = Tweet.create_from_weibo_html_fragment(ele)
        created_at = datetime.now() - timedelta(seconds=60*18)
        self.assertEquals(created_at.strftime('%Y%m%d %H%M%S'), t.created_at.strftime('%Y%m%d %H%M%S'))
Ejemplo n.º 2
0
    def test_tweet_should_have_created_at_time_when_create_it_from_weibo_html_fragment(
            self):
        ele = html.fromstring(weibo_sms_html_frag)
        t = Tweet.create_from_weibo_html_fragment(ele)
        created_at = datetime(2010, 11, 10, 11, 19)
        self.assertEquals(created_at.strftime('%Y%m%d %H%M%S'),
                          t.created_at.strftime('%Y%m%d %H%M%S'))

        m = weibo_sms_html_frag.replace(u'11月10日 11:19', '2009-8-29 16:55')
        ele = html.fromstring(m)
        t = Tweet.create_from_weibo_html_fragment(ele)
        created_at = datetime(2009, 8, 29, 16, 55)
        self.assertEquals(created_at.strftime('%Y%m%d %H%M%S'),
                          t.created_at.strftime('%Y%m%d %H%M%S'))

        m = weibo_sms_html_frag.replace(u'11月10日 11:19', u'18分钟前')
        ele = html.fromstring(m)
        t = Tweet.create_from_weibo_html_fragment(ele)
        created_at = datetime.now() - timedelta(seconds=60 * 18)
        self.assertEquals(created_at.strftime('%Y%m%d %H%M%S'),
                          t.created_at.strftime('%Y%m%d %H%M%S'))
Ejemplo n.º 3
0
 def test_tweet_should_have_profile_image_when_create_it_from_weibo_html_fragment(
         self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('http://tp3.sinaimg.cn/1661931502/50/1287680537/1',
                       t.profile_image)
Ejemplo n.º 4
0
 def test_tweet_should_have_id_when_create_it_from_weibo_html_fragment(
         self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals(211101110530573L, t.tweet_id)
Ejemplo n.º 5
0
 def test_weibo_tweet_should_use_original_content_as_text(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     ele = html.fromstring(t.text)
     self.assertEquals('MIB_feed_c', ele.get('class'))
Ejemplo n.º 6
0
 def test_weibo_tweet_should_have_uri(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('http://t.sina.com.cn/1661931502/24EN12e1D', t.uri)
Ejemplo n.º 7
0
 def test_weibo_tweet_should_be_weibo_race(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('weibo', t.race)
Ejemplo n.º 8
0
 def test_tweet_should_have_dump_which_is_the_original_html_fragment(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals(html.tostring(ele), t.dump)
Ejemplo n.º 9
0
 def test_tweet_should_have_dump_which_is_the_original_html_fragment(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals(html.tostring(ele), t.dump)
Ejemplo n.º 10
0
 def test_tweet_should_have_user_id_when_create_it_from_weibo_html_fragment(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals(u'蓝月鸟', t.tweet_user_name)
     self.assertEquals(1661931502L, t.tweet_user_id)
Ejemplo n.º 11
0
 def test_tweet_should_have_profile_image_when_create_it_from_weibo_html_fragment(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('http://tp3.sinaimg.cn/1661931502/50/1287680537/1', t.profile_image)
Ejemplo n.º 12
0
 def test_tweet_should_have_id_when_create_it_from_weibo_html_fragment(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals(211101110530573L, t.tweet_id)
Ejemplo n.º 13
0
 def test_weibo_tweet_should_use_original_content_as_text(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     ele = html.fromstring(t.text)
     self.assertEquals('MIB_feed_c', ele.get('class'))
Ejemplo n.º 14
0
 def test_weibo_tweet_should_have_uri(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('http://t.sina.com.cn/1661931502/24EN12e1D', t.uri)
Ejemplo n.º 15
0
 def test_weibo_tweet_should_be_weibo_race(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('weibo', t.race)
Ejemplo n.º 16
0
 def test_tweet_should_have_user_id_when_create_it_from_weibo_html_fragment(
         self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals(u'蓝月鸟', t.tweet_user_name)
     self.assertEquals(1661931502L, t.tweet_user_id)
Ejemplo n.º 17
0
 def test_tweet_should_have_source_when_create_it_from_weibo_html_fragment(
         self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('FaWave', t.source)
Ejemplo n.º 18
0
 def test_tweet_should_have_source_when_create_it_from_weibo_html_fragment(self):
     ele = html.fromstring(weibo_sms_html_frag)
     t = Tweet.create_from_weibo_html_fragment(ele)
     self.assertEquals('FaWave', t.source)