Permalink
Browse files

test mixed css files in precompiler tests

  • Loading branch information...
1 parent 23c240c commit ea9628123644ac212f549d2ee849828ef0a89ebb @peterlundberg peterlundberg committed Jan 16, 2012
Showing with 40 additions and 0 deletions.
  1. +40 −0 compressor/tests/templatetags.py
@@ -137,6 +137,7 @@ def setUp(self):
settings.COMPRESS_ENABLED = True
settings.COMPRESS_PRECOMPILERS = (
('text/coffeescript', '%s %s' % (python, precompiler)),
+ ('text/less', '%s %s' % (python, precompiler)),
)
self.context = {'MEDIA_URL': settings.COMPRESS_URL}
@@ -222,6 +223,45 @@ def test_multiple_file_order_conserved(self):
finally:
settings.COMPRESS_ENABLED = self.old_enabled
+ def test_css_multiple_files_disabled_compression(self):
+ self.old_enabled = settings.COMPRESS_ENABLED
+ settings.COMPRESS_ENABLED = False
+ assert(settings.COMPRESS_PRECOMPILERS)
+ try:
+ template = u"""
+ {% load compress %}{% compress css %}
+ <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/one.css"></link>
+ <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/two.css"></link>
+ {% endcompress %}"""
+
+ out = '\n'.join([
+ '<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
+ '<link rel="stylesheet" type="text/css" href="/media/css/two.css" />'])
+
+ self.assertEqual(out, render(template, self.context))
+ finally:
+ settings.COMPRESS_ENABLED = self.old_enabled
+
+ def test_css_multiple_files_mixed_precompile_disabled_compression(self):
+ self.old_enabled = settings.COMPRESS_ENABLED
+ settings.COMPRESS_ENABLED = False
+ assert(settings.COMPRESS_PRECOMPILERS)
+ try:
+ template = u"""
+ {% load compress %}{% compress css %}
+ <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/one.css"/>
+ <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/two.css"/>
+ <link rel="stylesheet" type="text/less" href="{{ MEDIA_URL }}css/url/test.css"/>
+ {% endcompress %}"""
+
+ out = '\n'.join([
+ '<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
+ '<link rel="stylesheet" type="text/css" href="/media/css/two.css" />',
+ '<link rel="stylesheet" href="/media/CACHE/css/test.c4f8a285c249.css" type="text/css" />'])
+ self.assertEqual(out, render(template, self.context))
+ finally:
+ settings.COMPRESS_ENABLED = self.old_enabled
+
def script(content="", src="", scripttype="text/javascript"):
"""
returns a unicode text html script element.

0 comments on commit ea96281

Please sign in to comment.