summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-10-27 10:30:28 -0400
committerTim Graham <timograham@gmail.com>2018-10-27 11:58:29 -0400
commitf892781b957f674806a227a10c58768f66a48c07 (patch)
tree050922b97e1c8c4f1509a1811ed5c412e433252f /tests/staticfiles_tests
parent55b0b766fbeb2f71e68331a2e14205702f681012 (diff)
Fixed #28606 -- Deprecated CachedStaticFilesStorage.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/storage.py8
-rw-r--r--tests/staticfiles_tests/test_management.py4
-rw-r--r--tests/staticfiles_tests/test_storage.py39
3 files changed, 26 insertions, 25 deletions
diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py
index 3214a68a00..b9cac3cd05 100644
--- a/tests/staticfiles_tests/storage.py
+++ b/tests/staticfiles_tests/storage.py
@@ -2,7 +2,7 @@ import os
from datetime import datetime, timedelta
from django.conf import settings
-from django.contrib.staticfiles.storage import CachedStaticFilesStorage
+from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
from django.core.files import storage
from django.utils import timezone
@@ -70,18 +70,18 @@ class QueryStringStorage(storage.Storage):
return path + '?a=b&c=d'
-class SimpleCachedStaticFilesStorage(CachedStaticFilesStorage):
+class SimpleStorage(ManifestStaticFilesStorage):
def file_hash(self, name, content=None):
return 'deploy12345'
-class ExtraPatternsCachedStaticFilesStorage(CachedStaticFilesStorage):
+class ExtraPatternsStorage(ManifestStaticFilesStorage):
"""
A storage class to test pattern substitutions with more than one pattern
entry. The added pattern rewrites strings like "url(...)" to JS_URL("...").
"""
- patterns = tuple(CachedStaticFilesStorage.patterns) + (
+ patterns = tuple(ManifestStaticFilesStorage.patterns) + (
(
"*.js", (
(r"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""", 'JS_URL("%s")'),
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index 20595ad118..1fdeaf78cc 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -201,13 +201,13 @@ class TestCollectionVerbosity(CollectionTestCase):
self.assertIn(self.staticfiles_copied_msg, output)
self.assertIn(self.copying_msg, output)
- @override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage')
+ @override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage')
def test_verbosity_1_with_post_process(self):
stdout = StringIO()
self.run_collectstatic(verbosity=1, stdout=stdout, post_process=True)
self.assertNotIn(self.post_process_msg, stdout.getvalue())
- @override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage')
+ @override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage')
def test_verbosity_2_with_post_process(self):
stdout = StringIO()
self.run_collectstatic(verbosity=2, stdout=stdout, post_process=True)
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py
index f7a22b7427..97e3b9113d 100644
--- a/tests/staticfiles_tests/test_storage.py
+++ b/tests/staticfiles_tests/test_storage.py
@@ -12,7 +12,8 @@ from django.contrib.staticfiles.management.commands.collectstatic import (
)
from django.core.cache.backends.base import BaseCache
from django.core.management import call_command
-from django.test import override_settings
+from django.test import SimpleTestCase, ignore_warnings, override_settings
+from django.utils.deprecation import RemovedInDjango31Warning
from .cases import CollectionTestCase
from .settings import TEST_ROOT
@@ -43,9 +44,6 @@ class TestHashedFiles:
pass
def test_template_tag_return(self):
- """
- Test the CachedStaticFilesStorage backend.
- """
self.assertStaticRaises(ValueError, "does/not/exist.png", "/static/does/not/exist.png")
self.assertStaticRenders("test/file.txt", "/static/test/file.dad0999e4f8f.txt")
self.assertStaticRenders("test/file.txt", "/static/test/file.dad0999e4f8f.txt", asvar=True)
@@ -232,6 +230,7 @@ class TestHashedFiles:
self.assertPostCondition()
+@ignore_warnings(category=RemovedInDjango31Warning)
@override_settings(
STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
)
@@ -299,10 +298,20 @@ class TestCollectionCachedStorage(TestHashedFiles, CollectionTestCase):
self.hashed_file_path('cached/styles.css')
-@override_settings(
- STATICFILES_STORAGE='staticfiles_tests.storage.ExtraPatternsCachedStaticFilesStorage',
-)
-class TestExtraPatternsCachedStorage(CollectionTestCase):
+class TestCachedStaticFilesStorageDeprecation(SimpleTestCase):
+ def test_warning(self):
+ from django.contrib.staticfiles.storage import CachedStaticFilesStorage
+ from django.utils.deprecation import RemovedInDjango31Warning
+ msg = (
+ 'CachedStaticFilesStorage is deprecated in favor of '
+ 'ManifestStaticFilesStorage.'
+ )
+ with self.assertRaisesMessage(RemovedInDjango31Warning, msg):
+ CachedStaticFilesStorage()
+
+
+@override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.ExtraPatternsStorage')
+class TestExtraPatternsStorage(CollectionTestCase):
def setUp(self):
storage.staticfiles_storage.hashed_files.clear() # avoid cache interference
@@ -437,13 +446,8 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase):
self.hashed_file_path(missing_file_name)
-@override_settings(
- STATICFILES_STORAGE='staticfiles_tests.storage.SimpleCachedStaticFilesStorage',
-)
-class TestCollectionSimpleCachedStorage(CollectionTestCase):
- """
- Tests for the Cache busting storage
- """
+@override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.SimpleStorage')
+class TestCollectionSimpleStorage(CollectionTestCase):
hashed_file_path = hashed_file_path
def setUp(self):
@@ -451,9 +455,6 @@ class TestCollectionSimpleCachedStorage(CollectionTestCase):
super().setUp()
def test_template_tag_return(self):
- """
- Test the CachedStaticFilesStorage backend.
- """
self.assertStaticRaises(ValueError, "does/not/exist.png", "/static/does/not/exist.png")
self.assertStaticRenders("test/file.txt", "/static/test/file.deploy12345.txt")
self.assertStaticRenders("cached/styles.css", "/static/cached/styles.deploy12345.css")
@@ -543,7 +544,7 @@ class TestStaticFilePermissions(CollectionTestCase):
@override_settings(
- STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
+ STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage',
)
class TestCollectionHashedFilesCache(CollectionTestCase):
"""