Example #1
0
    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!')
Example #2
0
    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!')
Example #3
0
 def test_with_unknown_vars(self):
     """Tests render_custom_content with unknown variables"""
     s = render_custom_content('{{settings.DEBUG}};{{settings.DATABASES}}')
     self.assertEqual(s, ';')
Example #4
0
 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" %}')
Example #5
0
 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 %}')
Example #6
0
 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" %}')
Example #7
0
 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 %}')
Example #8
0
 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 %})')
Example #9
0
 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" %}')
Example #10
0
 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" %}')
Example #11
0
 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 %}')
Example #12
0
 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" %}')
Example #13
0
 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 %}')
Example #14
0
 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 %})')
Example #15
0
 def test_with_unknown_vars(self):
     """Testing render_custom_content with unknown variables"""
     s = render_custom_content('{{settings.DEBUG}};{{settings.DATABASES}}')
     self.assertEqual(s, ';')
Example #16
0
 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" %}')