Skip to content

Commit c53a27e

Browse files
authored
Fix tests for SDK (#147)
* Separated tests for business endpoints to a new class. * Fixed bugs in tests.
1 parent fb9a531 commit c53a27e

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

test/test_dropbox.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def test_default_oauth2_urls(self):
7676
'http://localhost/dummy', 'dummy_session', 'dbx-auth-csrf-token')
7777

7878
six.assertRegex(
79+
self,
7980
flow_obj._get_authorize_url('http://localhost/redirect', 'state'),
8081
r'^https://{}/oauth2/authorize\?'.format(re.escape(session.WEB_HOST)),
8182
)
@@ -135,37 +136,12 @@ def test_bad_upload_types(self, dbx):
135136
with self.assertRaises(TypeError):
136137
dbx.files_upload(BytesIO(b'test'), '/Test')
137138

138-
@dbx_team_from_env
139-
def test_team(self, dbxt):
140-
dbxt.team_groups_list()
141-
r = dbxt.team_members_list()
142-
if r.members:
143-
# Only test assuming a member if there is a member
144-
team_member_id = r.members[0].profile.team_member_id
145-
dbxt.as_user(team_member_id).files_list_folder('')
146-
147-
@dbx_team_from_env
148-
def test_as_user(self, dbxt):
149-
dbx_as_user = dbxt.as_user('1')
150-
self.assertIsInstance(dbx_as_user, Dropbox)
151-
152-
@dbx_team_from_env
153-
def test_as_admin(self, dbxt):
154-
dbx_as_admin = dbxt.as_admin('1')
155-
self.assertIsInstance(dbx_as_admin, Dropbox)
156-
157139
@dbx_from_env
158140
def test_clone_when_user_linked(self, dbx):
159141
new_dbx = dbx.clone()
160142
self.assertIsNot(dbx, new_dbx)
161143
self.assertIsInstance(new_dbx, dbx.__class__)
162144

163-
@dbx_team_from_env
164-
def test_clone_when_team_linked(self, dbxt):
165-
new_dbxt = dbxt.clone()
166-
self.assertIsNot(dbxt, new_dbxt)
167-
self.assertIsInstance(new_dbxt, dbxt.__class__)
168-
169145
@dbx_from_env
170146
def test_with_path_root_constructor(self, dbx):
171147
# Verify valid mode types
@@ -215,5 +191,31 @@ def test_path_root_err(self, dbx):
215191
dbxpr.files_list_folder('')
216192
self.assertTrue(cm.exception.error.is_invalid_root())
217193

194+
class TestDropboxTeam(unittest.TestCase):
195+
@dbx_team_from_env
196+
def test_team(self, dbxt):
197+
dbxt.team_groups_list()
198+
r = dbxt.team_members_list()
199+
if r.members:
200+
# Only test assuming a member if there is a member
201+
team_member_id = r.members[0].profile.team_member_id
202+
dbxt.as_user(team_member_id).files_list_folder('')
203+
204+
@dbx_team_from_env
205+
def test_as_user(self, dbxt):
206+
dbx_as_user = dbxt.as_user('1')
207+
self.assertIsInstance(dbx_as_user, Dropbox)
208+
209+
@dbx_team_from_env
210+
def test_as_admin(self, dbxt):
211+
dbx_as_admin = dbxt.as_admin('1')
212+
self.assertIsInstance(dbx_as_admin, Dropbox)
213+
214+
@dbx_team_from_env
215+
def test_clone_when_team_linked(self, dbxt):
216+
new_dbxt = dbxt.clone()
217+
self.assertIsNot(dbxt, new_dbxt)
218+
self.assertIsInstance(new_dbxt, dbxt.__class__)
219+
218220
if __name__ == '__main__':
219221
unittest.main()

0 commit comments

Comments
 (0)