Skip to content

Commit 209bf39

Browse files
authored
Add route versioning support to transport module of Python SDK (dropbox#148)
1 parent c53a27e commit 209bf39

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

dropbox/dropbox.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ def request(self,
249249
"""
250250
host = route.attrs['host'] or 'api'
251251
route_name = namespace + '/' + route.name
252+
if route.version > 1:
253+
route_name += '_v{}'.format(route.version)
252254
route_style = route.attrs['style'] or 'rpc'
253255
serialized_arg = stone_serializers.json_encode(route.arg_type,
254256
request_arg)

test/test_dropbox.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
PathRootError,
3333
)
3434
from dropbox.files import (
35+
DeleteResult,
3536
ListFolderError,
3637
)
3738
from dropbox.common import (
@@ -191,6 +192,17 @@ def test_path_root_err(self, dbx):
191192
dbxpr.files_list_folder('')
192193
self.assertTrue(cm.exception.error.is_invalid_root())
193194

195+
@dbx_from_env
196+
def test_versioned_route(self, dbx):
197+
# Upload a test file
198+
path = '/test.txt'
199+
dbx.files_upload(DUMMY_PAYLOAD, path)
200+
201+
# Delete the file with v2 route
202+
resp = dbx.files_delete_v2(path)
203+
# Verify response type is of v2 route
204+
self.assertIsInstance(resp, DeleteResult)
205+
194206
class TestDropboxTeam(unittest.TestCase):
195207
@dbx_team_from_env
196208
def test_team(self, dbxt):

0 commit comments

Comments
 (0)