Merge pull request #673 from diox/add-multiple-context-tests

Add tests with multiple offline contexts with inheritance
This commit is contained in:
Mathieu Pillard
2015-10-02 12:45:48 +02:00
3 changed files with 56 additions and 2 deletions

View File

@@ -323,12 +323,23 @@ class OfflineCompressTestCaseWithContext(OfflineTestCaseMixin, TestCase):
}
class OfflineCompressTestCaseWithContextSuper(OfflineTestCaseMixin, TestCase):
templates_dir = 'test_with_context_super'
expected_hash = 'b1d0a333a4ef'
additional_test_settings = {
'COMPRESS_OFFLINE_CONTEXT': {
'content': 'OK!',
}
}
# Block.super not supported for Jinja2 yet.
engines = ('django',)
class OfflineCompressTestCaseWithContextList(OfflineTestCaseMixin, TestCase):
templates_dir = 'test_with_context'
expected_hash = ['f8bcaea049b3', 'db12749b1e80', 'e9f4a0054a06']
additional_test_settings = {
'COMPRESS_OFFLINE_CONTEXT': [{
'content': 'OK %d!' % i} for i in range(1, 4)]
'COMPRESS_OFFLINE_CONTEXT': list(offline_context_generator())
}
def _prepare_contexts(self, engine):
@@ -339,6 +350,17 @@ class OfflineCompressTestCaseWithContextList(OfflineTestCaseMixin, TestCase):
return None
class OfflineCompressTestCaseWithContextListSuper(
OfflineCompressTestCaseWithContextList):
templates_dir = 'test_with_context_super'
expected_hash = ['b11543f1e174', 'aedf6d2a7ec7', '0dbb8c29f23a']
additional_test_settings = {
'COMPRESS_OFFLINE_CONTEXT': list(offline_context_generator())
}
# Block.super not supported for Jinja2 yet.
engines = ('django',)
class OfflineCompressTestCaseWithContextGenerator(
OfflineTestCaseMixin, TestCase):
templates_dir = 'test_with_context'
@@ -358,6 +380,18 @@ class OfflineCompressTestCaseWithContextGenerator(
return None
class OfflineCompressTestCaseWithContextGeneratorSuper(
OfflineCompressTestCaseWithContextGenerator):
templates_dir = 'test_with_context_super'
expected_hash = ['b11543f1e174', 'aedf6d2a7ec7', '0dbb8c29f23a']
additional_test_settings = {
'COMPRESS_OFFLINE_CONTEXT': 'compressor.tests.test_offline.'
'offline_context_generator'
}
# Block.super not supported for Jinja2 yet.
engines = ('django',)
class OfflineCompressTestCaseWithContextGeneratorImportError(
OfflineTestCaseMixin, TestCase):
templates_dir = 'test_with_context'

View File

@@ -0,0 +1,7 @@
{% spaceless %}
{% block js %}
<script type="text/javascript">
alert("{{ content|default:"Ooops!" }}");
</script>
{% endblock %}
{% endspaceless %}

View File

@@ -0,0 +1,13 @@
{% extends "base.html" %}
{% load compress %}
{% block js %}{% spaceless %}
{% compress js %}
{{ block.super }}
<script type="text/javascript">
alert("this alert shouldn't be alone!");
</script>
{% endcompress %}
{% endspaceless %}{% endblock %}
{% block css %}{% endblock %}