Esempio n. 1
0
 def test_list(self):
     expected = [
         os.path.join('repo1', 't1', 'template.j2'),
         os.path.join('repo2', 't1', 'template.j2'),
         os.path.join('repo2', 't2', 'template.j2'),
     ]
     loader = FileSystemLoader(self.root_folder)
     assert_items_equal(expected, loader.list_templates())
Esempio n. 2
0
 def test_get_source_removes_tags(self, exists_m, open_m, getmtime_m):
     exists_m.return_value = True
     open_m.return_value = MagicMock(spec=file)
     file_handle = open_m.return_value.__enter__.return_value
     file_handle.read.return_value = TEMPLATE_WITH_INVALID_TAGS
     loader = FileSystemLoader(self.root_folder)
     source, path, update = loader.get_source(Mock(), 't')
     expected_path = os.path.join(self.root_folder, 't')
     assert expected_path == path
     expected_source = '''
     <html>
         <head>
         </head>
         <body>
             <p>Hi <span>world</span></p>
         </body>
     </html>
     '''
     assert self.clean_string(expected_source) == self.clean_string(source)
Esempio n. 3
0
 def test_get_source_raises_error_if_no_template(self):
     loader = FileSystemLoader(self.root_folder)
     with pytest.raises(TemplateNotFound):
         loader.get_source(Mock(), 't')