def _access_token(access_token, userinfo=None): if userinfo is None: userinfo = get_user_info(access_token) attributes = {'access_token_str': str(access_token), 'twitter_id': userinfo.id, 'userinfo_json': userinfo.AsJsonString()} return (attributes, userinfo)
def _access_token(access_token, userinfo=None): if userinfo is None: userinfo = get_user_info(access_token) attributes = { 'access_token_str': str(access_token), 'twitter_id': userinfo.id, 'userinfo_json': userinfo.AsJsonString() } return (attributes, userinfo)
def cached_user_info(request, token): userinfo = None try: userinfo = get_user_info(token) except: pass if userinfo is None: # Look for a cached copy in the session if USERINFO_KEY in request.session: userinfo_dict = simplejson.loads(request.session[USERINFO_KEY]) userinfo = twitter.User.NewFromJsonDict(userinfo_dict) else: request.session[USERINFO_KEY] = userinfo.AsJsonString() return userinfo
def test_get_user_info(self): Api = self.mocker.replace(TwitterApi) Api(TOKEN).GetUserInfo() self.mocker.result('GetUserInfo') with self.mocker: self.assertEqual(get_user_info(TOKEN), 'GetUserInfo')