added additional tests
This commit is contained in:
@@ -40,6 +40,10 @@ class TestJinja2CompressorExtension(TestCase):
|
|||||||
self.assertRaises(self.jinja2.exceptions.TemplateSyntaxError,
|
self.assertRaises(self.jinja2.exceptions.TemplateSyntaxError,
|
||||||
self.env.from_string, '{% compress foo %}Foobar{% endcompress %}')
|
self.env.from_string, '{% compress foo %}Foobar{% endcompress %}')
|
||||||
|
|
||||||
|
def test_error_raised_if_wrong_closing_kind_given(self):
|
||||||
|
self.assertRaises(self.jinja2.exceptions.TemplateSyntaxError,
|
||||||
|
self.env.from_string, '{% compress js %}Foobar{% endcompress css %}')
|
||||||
|
|
||||||
def test_error_raised_if_wrong_mode_given(self):
|
def test_error_raised_if_wrong_mode_given(self):
|
||||||
self.assertRaises(self.jinja2.exceptions.TemplateSyntaxError,
|
self.assertRaises(self.jinja2.exceptions.TemplateSyntaxError,
|
||||||
self.env.from_string, '{% compress css foo %}Foobar{% endcompress %}')
|
self.env.from_string, '{% compress css foo %}Foobar{% endcompress %}')
|
||||||
@@ -55,12 +59,23 @@ class TestJinja2CompressorExtension(TestCase):
|
|||||||
template = self.env.from_string(template_string)
|
template = self.env.from_string(template_string)
|
||||||
self.assertEqual(tag_body, template.render())
|
self.assertEqual(tag_body, template.render())
|
||||||
|
|
||||||
|
# Test with explicit kind
|
||||||
|
template_string = '{% compress css %}' + tag_body + '{% endcompress css %}'
|
||||||
|
template = self.env.from_string(template_string)
|
||||||
|
self.assertEqual(tag_body, template.render())
|
||||||
|
|
||||||
def test_empty_tag(self):
|
def test_empty_tag(self):
|
||||||
template = self.env.from_string("""{% compress js %}{% block js %}
|
template = self.env.from_string("""{% compress js %}{% block js %}
|
||||||
{% endblock %}{% endcompress %}""")
|
{% endblock %}{% endcompress %}""")
|
||||||
context = {'STATIC_URL': settings.COMPRESS_URL}
|
context = {'STATIC_URL': settings.COMPRESS_URL}
|
||||||
self.assertEqual('', template.render(context))
|
self.assertEqual('', template.render(context))
|
||||||
|
|
||||||
|
def test_empty_tag_with_kind(self):
|
||||||
|
template = self.env.from_string("""{% compress js %}{% block js %}
|
||||||
|
{% endblock %}{% endcompress js %}""")
|
||||||
|
context = {'STATIC_URL': settings.COMPRESS_URL}
|
||||||
|
self.assertEqual('', template.render(context))
|
||||||
|
|
||||||
def test_css_tag(self):
|
def test_css_tag(self):
|
||||||
template = self.env.from_string("""{% compress css -%}
|
template = self.env.from_string("""{% compress css -%}
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}css/one.css" type="text/css" charset="utf-8">
|
<link rel="stylesheet" href="{{ STATIC_URL }}css/one.css" type="text/css" charset="utf-8">
|
||||||
|
Reference in New Issue
Block a user