def url(self): try: uid = self._data['user']['id'] mid = get_mid(self._data['mid']) except KeyError: # Sometimes Sina's API doesn't return user # when our tweet is deeply nested. Just forgot it. return "" return 'http://weibo.com/%s/%s' % (uid, mid)
def test_get_mid(self): self.assertEqual(get_mid("3591268992667779"), 'zCik3bc0H') self.assertEqual(get_mid("3591370117495972"), 'zCkX9vs2M') self.assertEqual(get_mid("3591291856713634"), 'zCiUVsawq')
def mid(self): decimal_mid = str(self._data.get('mid')) encode_mid = get_mid(decimal_mid) return encode_mid