Exemple #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'))
Exemple #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'))
Exemple #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)
Exemple #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)
Exemple #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'))
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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'))
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)