| Total Complexity | 7 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from pages.checks import page_templates_loading_check |
||
| 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 |