def test_with_valid_template(self): """Testing render_custom_content with a valid template""" s = render_custom_content( '{% if mybool %}{{s1}}{% else %}{{s2}}{% endif %}', { 'mybool': True, 's1': 'Hi!', 's2': 'Bye!', }) self.assertEqual(s, 'Hi!')
def test_with_unknown_vars(self): """Tests render_custom_content with unknown variables""" s = render_custom_content('{{settings.DEBUG}};{{settings.DATABASES}}') self.assertEqual(s, ';')
def test_with_blocked_ssi_tag(self): """Tests render_custom_content with blocked {% ssi %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'ssi'"): render_custom_content('{% ssi "foo.html" %}')
def test_with_blocked_load_tag(self): """Tests render_custom_content with blocked {% load %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'load'"): render_custom_content('{% load i18n %}')
def test_with_blocked_include_tag(self): """Tests render_custom_content with blocked {% include %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'include'"): render_custom_content('{% include "base.html" %}')
def test_with_blocked_debug_tag(self): """Tests render_custom_content with blocked {% debug %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'debug'"): render_custom_content('{% debug %}')
def test_with_blocked_block_tag(self): """Tests render_custom_content with blocked {% block %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'block'"): render_custom_content('{% block foo %}{% endblock %})')
def test_with_blocked_extends_tag(self): """Testing render_custom_content with blocked {% extends %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'extends'"): render_custom_content('{% extends "base.html" %}')
def test_with_blocked_ssi_tag(self): """Testing render_custom_content with blocked {% ssi %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'ssi'"): render_custom_content('{% ssi "foo.html" %}')
def test_with_blocked_load_tag(self): """Testing render_custom_content with blocked {% load %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'load'"): render_custom_content('{% load i18n %}')
def test_with_blocked_include_tag(self): """Testing render_custom_content with blocked {% include %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'include'"): render_custom_content('{% include "base.html" %}')
def test_with_blocked_debug_tag(self): """Testing render_custom_content with blocked {% debug %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'debug'"): render_custom_content('{% debug %}')
def test_with_blocked_block_tag(self): """Testing render_custom_content with blocked {% block %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'block'"): render_custom_content('{% block foo %}{% endblock %})')
def test_with_unknown_vars(self): """Testing render_custom_content with unknown variables""" s = render_custom_content('{{settings.DEBUG}};{{settings.DATABASES}}') self.assertEqual(s, ';')
def test_with_blocked_extends_tag(self): """Tests render_custom_content with blocked {% extends %}""" with self.assertRaisesMessage(TemplateSyntaxError, "Invalid block tag: 'extends'"): render_custom_content('{% extends "base.html" %}')