8000 Fix test on Django < 1.10 · django-cms/django-cms@10bc8a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10bc8a5

Browse files
author
Pankrat
committed
Fix test on Django < 1.10
Don't fail if the static files storage is not called at all. On Django 1.8 and 1.9, `StaticNode` doesn't use the static files storage for looking up static files. This was changed in this commit: django/django@cf546e1
1 parent caabd98 commit 10bc8a5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

cms/tests/test_templatetags.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,22 @@ def test_static_with_version_manifest(self, mock_storage):
111111
stored when using static file manifests.
112112
"""
113113
mock_storage.url.side_effect = lambda x: '/static/' + x
114-
expected = 'cms/css/%(version)s/cms.base.css'
115-
expected = expected % {'version': cms.__version__}
116114

117115
template = (
118-
"""{% load cms_static %}<script src="{% static_with_version "cms/css/cms.base.css" %}" """
116+
"""{% load staticfiles cms_static %}<script src="{% static_with_version "cms/css/cms.base.css" %}" """
119117
"""type="text/javascript"></script>"""
120118
)
121119

122-
self.render_template_obj(template, {}, None)
123-
mock_storage.url.assert_called_with(expected)
120+
output = self.render_template_obj(template, {}, None)
121+
# If the manifest is used for looking up the static file (Django 1.10
122+
# and later), it needs to be looked up with a proper path.
123+
versioned_filename = 'cms/css/%s/cms.base.css' % cms.__version__
124+
if mock_storage.url.called:
125+
mock_storage.url.assert_called_with(versioned_filename)
126+
127+
expected = '<script src="/static/%s" type="text/javascript"></script>'
128+
expected = expected % versioned_filename
129+
self.assertEqual(expected, output)
124130

125131

126132
class TemplatetagDatabaseTests(TwoPagesFixture, CMSTestCase):

0 commit comments

Comments
 (0)
0