Example #1
0
    def test_template_loader_load_template(self):
        loader = TemplateLoader(template_path="examples/template/")
        loader_loaded_template = loader.load_template("login.htm")
        with open("examples/template/login.htm") as f:
            test_loaded_template = jinja2.Template(f.read())

        self.assertEqual(loader_loaded_template.render(), test_loaded_template.render())
Example #2
0
 def test_template_loader_load_template_cache(self):
     loader = TemplateLoader(template_path="examples/template/")
     first_loaded_template = loader.load_template("login.htm")
     second_loaded_template = loader.load_template("login.htm")
     self.assertIs(first_loaded_template, second_loaded_template)
Example #3
0
 def test_template_loader_load_template_file_content(self):
     loader = TemplateLoader(template_path="examples/template/")
     file_path = loader.find_abs_path("login.htm")
     with open("examples/template/login.htm") as f:
         self.assertEqual(f.read(), loader.load_template_file_content(file_path))
Example #4
0
 def test_template_loader_find_abs_path(self):
     loader = TemplateLoader(template_path="examples/template/")
     file_path = loader.find_abs_path("login.htm")
     self.assertEqual(file_path, os.path.realpath("examples/template/login.htm"))
     self.assertRaises(FileNotFoundError, loader.find_abs_path, "login.html")