コード例 #1
0
 def test_token(self, token):
     team = DropboxTeam(token)
     try:
         team.team_get_info()
         return True
     except Exception:
         print "Please check your OAuth2 token"
         return False
コード例 #2
0
 def test_token(self, token):
     team = DropboxTeam(token)
     try:
         team.team_get_info()
         return True
     except Exception:
         print "Please check your OAuth2 token"
         return False
コード例 #3
0
class TestDropbox(unittest.TestCase):

    def setUp(self):
        self.dbx = Dropbox(oauth2_token)
        self.dbxt = DropboxTeam(team_oauth2_token)

    def test_bad_auth(self):
        # Test malformed token
        malformed_token_dbx = Dropbox(MALFORMED_TOKEN)
        with self.assertRaises(BadInputError) as cm:
            malformed_token_dbx.files_list_folder('')
        self.assertIn('token is malformed', cm.exception.message)

        # Test reasonable-looking invalid token
        invalid_token_dbx = Dropbox(INVALID_TOKEN)
        with self.assertRaises(AuthError) as cm:
            invalid_token_dbx.files_list_folder('')
        self.assertEqual(cm.exception.error['error']['.tag'],
                         'invalid_access_token')

    def test_rpc(self):
        self.dbx.files_list_folder('')

        # Test API error
        random_folder_path = '/' + \
                             ''.join(random.sample(string.ascii_letters, 15))
        with self.assertRaises(ApiError) as cm:
            self.dbx.files_list_folder(random_folder_path)
        self.assertIsInstance(cm.exception.error, ListFolderError)

    def test_upload_download(self):
        # Upload file
        timestamp = str(datetime.datetime.utcnow())
        random_filename = ''.join(random.sample(string.ascii_letters, 15))
        random_path = '/Test/%s/%s' % (timestamp, random_filename)
        test_contents = string.ascii_letters
        self.dbx.files_upload(test_contents, random_path)

        # Download file
        metadata, resp = self.dbx.files_download(random_path)
        self.assertEqual(string.ascii_letters, resp.text)

        # Cleanup folder
        self.dbx.files_delete('/Test/%s' % timestamp)

    def test_team(self):
        self.dbxt.team_groups_list()
        r = self.dbxt.team_members_list()
        if r.members:
            # Only test assuming a member if there is a member
            self.dbxt.as_user(r.members[0].profile.team_member_id).files_list_folder('')
コード例 #4
0
class TestDropbox(unittest.TestCase):
    def setUp(self):
        self.dbx = Dropbox(oauth2_token)
        self.dbxt = DropboxTeam(team_oauth2_token)

    def test_bad_auth(self):
        # Test malformed token
        malformed_token_dbx = Dropbox(MALFORMED_TOKEN)
        with self.assertRaises(BadInputError) as cm:
            malformed_token_dbx.files_list_folder('')
        self.assertIn('token is malformed', cm.exception.message)

        # Test reasonable-looking invalid token
        invalid_token_dbx = Dropbox(INVALID_TOKEN)
        with self.assertRaises(AuthError) as cm:
            invalid_token_dbx.files_list_folder('')
        self.assertEqual(cm.exception.error['error']['.tag'],
                         'invalid_access_token')

    def test_rpc(self):
        self.dbx.files_list_folder('')

        # Test API error
        random_folder_path = '/' + \
                             ''.join(random.sample(string.ascii_letters, 15))
        with self.assertRaises(ApiError) as cm:
            self.dbx.files_list_folder(random_folder_path)
        self.assertIsInstance(cm.exception.error, ListFolderError)

    def test_upload_download(self):
        # Upload file
        timestamp = str(datetime.datetime.utcnow())
        random_filename = ''.join(random.sample(string.ascii_letters, 15))
        random_path = '/Test/%s/%s' % (timestamp, random_filename)
        test_contents = string.ascii_letters
        self.dbx.files_upload(test_contents, random_path)

        # Download file
        metadata, resp = self.dbx.files_download(random_path)
        self.assertEqual(string.ascii_letters, resp.text)

        # Cleanup folder
        self.dbx.files_delete('/Test/%s' % timestamp)

    def test_team(self):
        self.dbxt.team_groups_list()
        r = self.dbxt.team_members_list()
        if r.members:
            # Only test assuming a member if there is a member
            self.dbxt.as_user(
                r.members[0].profile.team_member_id).files_list_folder('')
コード例 #5
0
 def test_team(self, token):
     dbxt = DropboxTeam(token)
     dbxt.team_groups_list()
     r = dbxt.team_members_list()
     if r.members:
         # Only test assuming a member if there is a member
         dbxt.as_user(r.members[0].profile.team_member_id).files_list_folder('')
コード例 #6
0
 def __init__(self, team_token, outfile, external_user_only=False):
     self.outfile = outfile
     self.external_user_only = external_user_only  # type: bool
     self.dropbox_team = DropboxTeam(team_token)
     self.member_loader = CachedLoader(MemberLoader(self.dropbox_team))
     self.member_resolver_by_account_id = MemberResolverLoader(
         self.member_loader)
     self.member_resolver_by_email = CachedResolver(
         MemberResolver(self.dropbox_team))
     self.account_resolver = CachedResolver(AccountResolver())
コード例 #7
0
 def wrapped(self, *args, **kwargs):
     team_oauth2_token = _token_from_env_or_die('DROPBOX_TEAM_TOKEN')
     args += (DropboxTeam(team_oauth2_token), )
     return f(self, *args, **kwargs)
コード例 #8
0
def dbx_team_from_env():
    team_oauth2_token = _value_from_env_or_die('DROPBOX_TEAM_TOKEN')
    return DropboxTeam(team_oauth2_token)
コード例 #9
0
 def setUp(self):
     self.dbx = Dropbox(oauth2_token)
     self.dbxt = DropboxTeam(team_oauth2_token)
コード例 #10
0
 def setUp(self):
     self.dbx = Dropbox(oauth2_token)
     self.dbxt = DropboxTeam(team_oauth2_token)