Files
deb-python-django-compressor/compressor/tests/test_mtime_cache.py
Patrick Michaud c2c37c7c30 Insert semicolon between JS files, fixes a JS syntax error when certain files are combined (#813)
compressor will turn files that look like

File1.js:
(function($) { console.log("run"); })(window)

File2.js:
(function($) { console.log("run 2"); })(window)

Into:
(function($) { console.log("run"); })(window)
(function($) { console.log("run 2"); })(window)

which will give an error like "Uncaught TypeError: (intermediate value)(...) is not a function"

This commit changes that output to:

(function($) { console.log("run"); })(window);(function($) { console.log("run 2"); })(window)
2017-01-03 08:50:02 +01:00

38 lines
1.3 KiB
Python

from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import TestCase
from django.utils.six import StringIO
class TestMtimeCacheCommand(TestCase):
# FIXME: add actual tests, improve the existing ones.
exclusion_patterns = [
'*CACHE*', '*custom*', '*d728fc7f9301.js', 'test.txt*'
]
def default_ignore(self):
return ['--ignore=%s' % pattern for pattern in self.exclusion_patterns]
def test_handle_no_args(self):
with self.assertRaises(CommandError):
call_command('mtime_cache')
def test_handle_add(self):
out = StringIO()
with self.settings(CACHES={}):
call_command(
'mtime_cache', '--add', *self.default_ignore(), stdout=out)
output = out.getvalue()
self.assertIn('Deleted mtimes of 20 files from the cache.', output)
self.assertIn('Added mtimes of 20 files to cache.', output)
def test_handle_clean(self):
out = StringIO()
with self.settings(CACHES={}):
call_command(
'mtime_cache', '--clean', *self.default_ignore(), stdout=out)
output = out.getvalue()
self.assertIn('Deleted mtimes of 20 files from the cache.', output)
self.assertNotIn('Added mtimes of 20 files to cache.', output)