Skip to content

Commit

Permalink
[dropbox] restore backwards compat for parameter order
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneier committed Aug 6, 2022
1 parent 7a89d73 commit 0cbb41b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions storages/backends/dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class DropBoxStorage(Storage):
def __init__(
self,
oauth2_access_token=oauth2_access_token,
app_key=app_key,
app_secret=app_secret,
oauth2_refresh_token=oauth2_refresh_token,
root_path=location,
timeout=timeout,
write_mode=write_mode,
app_key=app_key,
app_secret=app_secret,
oauth2_refresh_token=oauth2_refresh_token,
):
if oauth2_access_token is None and not all(
[app_key, app_secret, oauth2_refresh_token]
Expand Down
15 changes: 9 additions & 6 deletions tests/test_dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from datetime import datetime
from unittest import mock

from django.core.exceptions import ImproperlyConfigured
from django.core.exceptions import (
ImproperlyConfigured, SuspiciousFileOperation,
)
from django.core.files.base import File
from django.test import TestCase
from dropbox.files import FileMetadata, FolderMetadata, GetTemporaryLinkResult
Expand Down Expand Up @@ -185,17 +187,18 @@ def test_server_bad_response(self, *args):
return_value=FILES_EMPTY_MOCK)
class DropBoxRootPathTest(TestCase):
def test_jailed(self, *args):
self.storage = dropbox.DropBoxStorage('foo', '/bar')
self.storage = dropbox.DropBoxStorage('foo', root_path='/bar')
dirs, files = self.storage.listdir('/')
self.assertFalse(dirs)
self.assertFalse(files)

def test_relative_path(self, *args):
self.storage = dropbox.DropBoxStorage('foo', '/bar')
self.assertEqual('/', self.storage._full_path('..'))
def test_suspicious(self, *args):
self.storage = dropbox.DropBoxStorage('foo', root_path='/bar')
with self.assertRaises((SuspiciousFileOperation, ValueError)):
self.storage._full_path('..')

def test_formats(self, *args):
self.storage = dropbox.DropBoxStorage('foo', '/bar')
self.storage = dropbox.DropBoxStorage('foo', root_path='/bar')
files = self.storage._full_path('')
self.assertEqual(files, self.storage._full_path('/'))
self.assertEqual(files, self.storage._full_path('.'))

0 comments on commit 0cbb41b

Please sign in to comment.