def setUp(self): from netprintbox.data import OAuthRequestToken super(DropboxServiceSetupTest, self).setUp() token = 'oauth_token=token&oauth_token_secret=secret' token = OAuthRequestToken(key=self.key, token=token) token.put() class client(object): @staticmethod def account_info(): return {'uid': self.uid, 'email': 'email', 'display_name': 'display_name', 'country': 'JP', } class session(object): @staticmethod def obtain_access_token(request_token): pass class token(object): key = 'access_key' secret = 'access_secret' import dropbox.client import dropbox.session mock('dropbox.client.DropboxClient', returns=client) mock('dropbox.session.DropboxSession', returns=session)
def build_authorize_url(cls, callback_url): session = cls.get_session() request_token = session.obtain_request_token() token = OAuthRequestToken(key=request_token.key, token=str(request_token)) token.put() return session.build_authorize_url(request_token, callback_url)