summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@sixmedia.com>2014-02-12 22:07:23 +0700
committerTim Graham <timograham@gmail.com>2014-02-12 11:00:01 -0500
commit7e27885c6e7588471fd94a4def16b7081577bdfc (patch)
tree1ecf0b9d552de8ea630831385112a0a451af3f00 /tests/staticfiles_tests
parent73f51e411372ba3e74ccf5a2c2be88927ac2c6dd (diff)
Reworked the detection of local storages for the collectstatic command.
Before 4befb30 the detection was broken because we used isinstance against a LazyObject rather than against a Storage class. That commit fixed it by looking directly at the object wrapped by LazyObject. This could however be a problem to anyone who subclasses the collectstatic management Command and directly supplies a Storage class. Refs #21581.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/tests.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/tests.py b/tests/staticfiles_tests/tests.py
index e72875566b..21ecf84bbc 100644
--- a/tests/staticfiles_tests/tests.py
+++ b/tests/staticfiles_tests/tests.py
@@ -23,6 +23,9 @@ from django.utils import six
from django.contrib.staticfiles import finders, storage
from django.contrib.staticfiles.management.commands import collectstatic
+from .storage import DummyStorage
+
+
TEST_ROOT = os.path.dirname(upath(__file__))
TEST_SETTINGS = {
'DEBUG': True,
@@ -263,6 +266,29 @@ class TestConfiguration(StaticFilesTestCase):
'without having set the STATIC_ROOT setting to a filesystem path'):
call_command('collectstatic', interactive=False, verbosity=0, stderr=err)
+ def test_local_storage_detection_helper(self):
+ staticfiles_storage = storage.staticfiles_storage
+ try:
+ storage.staticfiles_storage._wrapped = empty
+ with override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage'):
+ command = collectstatic.Command()
+ self.assertTrue(command.is_local_storage())
+
+ storage.staticfiles_storage._wrapped = empty
+ with override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.DummyStorage'):
+ command = collectstatic.Command()
+ self.assertFalse(command.is_local_storage())
+
+ storage.staticfiles_storage = storage.FileSystemStorage()
+ command = collectstatic.Command()
+ self.assertTrue(command.is_local_storage())
+
+ storage.staticfiles_storage = DummyStorage()
+ command = collectstatic.Command()
+ self.assertFalse(command.is_local_storage())
+ finally:
+ storage.staticfiles_storage = staticfiles_storage
+
class TestCollection(CollectionTestCase, TestDefaults):
"""