PageTemplatesLoadingCheckTestCase   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 20
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_check_detects_unexistant_template() 0 8 2
A test_check_doesnt_warn_on_existing_templates() 0 5 2
A test_template_syntax_error_is_not_silenced() 0 4 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