Loading django/core/files/storage.py +2 −0 Original line number Diff line number Diff line Loading @@ -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') Loading Loading @@ -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 Loading tests/field_deconstruction/tests.py +2 −0 Original line number Diff line number Diff line Loading @@ -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): Loading Loading @@ -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") Loading tests/file_storage/tests.py +17 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
django/core/files/storage.py +2 −0 Original line number Diff line number Diff line Loading @@ -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') Loading Loading @@ -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 Loading
tests/field_deconstruction/tests.py +2 −0 Original line number Diff line number Diff line Loading @@ -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): Loading Loading @@ -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") Loading
tests/file_storage/tests.py +17 −0 Original line number Diff line number Diff line Loading @@ -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 Loading