summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-05-06 22:23:23 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-05-06 22:24:39 -0700
commitf53d1576caab1594b29f6215604ef23ab6e5745e (patch)
tree9047cc2d26ef6339df7bb415965e185367de406b
parenta75318e813c50e16550eb889fa0c375fa19b88b9 (diff)
[1.7.x] Fixed #22337: FileSystemStorage marked as deconstructible and tested.
-rw-r--r--django/core/files/storage.py2
-rw-r--r--tests/field_deconstruction/tests.py2
-rw-r--r--tests/file_storage/tests.py17
3 files changed, 21 insertions, 0 deletions
diff --git a/django/core/files/storage.py b/django/core/files/storage.py
index ade1817dad..3e600fb913 100644
--- a/django/core/files/storage.py
+++ b/django/core/files/storage.py
@@ -13,6 +13,7 @@ from django.utils.module_loading import import_string
from django.utils.six.moves.urllib.parse import urljoin
from django.utils.text import get_valid_filename
from django.utils._os import safe_join, abspathu
+from django.utils.deconstruct import deconstructible
__all__ = ('Storage', 'FileSystemStorage', 'DefaultStorage', 'default_storage')
@@ -144,6 +145,7 @@ class Storage(object):
raise NotImplementedError('subclasses of Storage must provide a modified_time() method')
+@deconstructible
class FileSystemStorage(Storage):
"""
Standard filesystem storage
diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py
index 2aaaad988b..0cf015ef06 100644
--- a/tests/field_deconstruction/tests.py
+++ b/tests/field_deconstruction/tests.py
@@ -3,6 +3,7 @@ import warnings
from django.db import models
from django.test import TestCase, override_settings
from django.utils import six
+from django.core.files.storage import FileSystemStorage
class FieldDeconstructionTests(TestCase):
@@ -141,6 +142,7 @@ class FieldDeconstructionTests(TestCase):
self.assertEqual(path, "django.db.models.FileField")
self.assertEqual(args, [])
self.assertEqual(kwargs, {"upload_to": "foo/bar"})
+ # Test max_length
field = models.FileField(upload_to="foo/bar", max_length=200)
name, path, args, kwargs = field.deconstruct()
self.assertEqual(path, "django.db.models.FileField")
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index 4ffba851eb..a0e2e2a6cc 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -64,6 +64,23 @@ class GetStorageClassTests(SimpleTestCase):
'django.core.files.non_existing_storage.NonExistingStorage')
+class FileStorageDeconstructionTests(unittest.TestCase):
+
+ def test_deconstruction(self):
+ path, args, kwargs = temp_storage.deconstruct()
+ self.assertEqual(path, "django.core.files.storage.FileSystemStorage")
+ self.assertEqual(args, tuple())
+ self.assertEqual(kwargs, {'location': temp_storage_location})
+
+ kwargs_orig = {
+ 'location': temp_storage_location,
+ 'base_url': 'http://myfiles.example.com/'
+ }
+ storage = FileSystemStorage(**kwargs_orig)
+ path, args, kwargs = storage.deconstruct()
+ self.assertEqual(kwargs, kwargs_orig)
+
+
class FileStorageTests(unittest.TestCase):
storage_class = FileSystemStorage