test_template_syntax_error_is_not_silenced()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 3
1
from pages.checks import page_templates_loading_check
2
3
from django.test import TestCase
4
from django.core.checks import Warning
5
from django.template import TemplateSyntaxError
6
7
8
class PageTemplatesLoadingCheckTestCase(TestCase):
9
    def test_check_detects_unexistant_template(self):
10
        unexistant = ('does_not_exists.html', 'foo')
11
        with self.settings(PAGE_TEMPLATES=[unexistant]):
12
            errors = page_templates_loading_check([])
13
14
        self.assertEqual(errors, [Warning(
15
            'Django cannot find template does_not_exists.html',
16
            obj=unexistant, id='pages.W001')])
17
18
    def test_check_doesnt_warn_on_existing_templates(self):
19
        with self.settings(PAGE_TEMPLATES=[('pages/contact.html', 'bas')]):
20
            errors = page_templates_loading_check([])
21
22
        self.assertEquals(errors, [])
23
24
    def test_template_syntax_error_is_not_silenced(self):
25
        with self.settings(PAGE_TEMPLATES=[('syntax_error.html', 'fail')]):
26
            with self.assertRaises(TemplateSyntaxError):
27
                page_templates_loading_check([])
28