8000 Add test for looking up versioned static files · django-cms/django-cms@caabd98 · GitHub
[go: up one dir, main page]

Skip to content

Commit caabd98

Browse files
author
Pankrat
committed
Add test for looking up versioned static files
1 parent 763fe80 commit caabd98

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cms/tests/test_templatetags.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
from django.core import mail
1111
from django.core.exceptions import ImproperlyConfigured
1212
from django.test import RequestFactory
13+
from django.test.utils import override_settings
1314
from django.utils.html import escape
1415
from django.utils.timezone import now
1516
from djangocms_text_ckeditor.cms_plugins import TextPlugin
1617

1718
from sekizai.data import UniqueSequence
1819
from sekizai.helpers import get_varname
1920

21+
from mock import patch
22+
2023
import cms
2124
from cms.api import create_page, create_title, add_plugin
2225
from cms.middleware.toolbar import ToolbarMiddleware
@@ -100,6 +103,25 @@ def test_static_with_version(self):
100103
output = self.render_template_obj(template, {}, None)
101104
self.assertEqual(expected, output)
102105

106+
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage')
107+
@patch('django.contrib.staticfiles.storage.staticfiles_storage')
108+
def test_static_with_version_manifest(self, mock_storage):
109+
"""
110+
Check that static files are looked up at the location where they are
111+
stored when using static file manifests.
112+
"""
113+
mock_storage.url.side_effect = lambda x: '/static/' + x
114+
expected = 'cms/css/%(version)s/cms.base.css'
115+
expected = expected % {'version': cms.__version__}
116+
117+
template = (
118+
"""{% load cms_static %}<script src="{% static_with_version "cms/css/cms.base.css" %}" """
119+
"""type="text/javascript"></script>"""
120+
)
121+
122+
self.render_template_obj(template, {}, None)
123+
mock_storage.url.assert_called_with(expected)
124+
103125

104126
class TemplatetagDatabaseTests(TwoPagesFixture, CMSTestCase):
105127
def _getfirst(self):

0 commit comments

Comments
 (0)
0