def test_file_tests(): output = "test.txt" path = os.path.join("tests", "fixtures", "jinja_tests") engine = Engine([path], path) engine.render_to_file("file_tests.template", "file_tests.yml", output) with open(output, "r") as output_file: content = output_file.read() eq_(content, "yes\nhere") os.unlink(output)
def test_globals(): output = "globals.txt" test_dict = dict(hello="world") jinja_global("test", test_dict) path = os.path.join("tests", "fixtures", "globals") engine = Engine([path], path) engine.render_to_file("basic.template", "basic.yml", output) with open(output, "r") as output_file: content = output_file.read() eq_(content, "world\n\ntest") os.unlink(output)
def test_do_templates_with_more_shared_data(): base_dir = os.path.join("tests", "fixtures") engine = Engine(base_dir, os.path.join(base_dir, "config")) engine._render_with_finding_data_first( {os.path.join(base_dir, "child.yaml"): [("a.jj2", "test")]}) with open("test", "r") as f: content = f.read() assert content == "hello world ox" os.unlink("test") if os.path.exists(".moban.hashes"): os.unlink(".moban.hashes")
def test_do_templates_1(_do_templates_with_more_shared_data): jobs = [ ("1.template", "data.yml", "1.output"), ("2.template", "data.yml", "2.output"), ("3.template", "data.yml", "3.output"), ("4.template", "data.yml", "4.output"), ("5.template", "data.yml", "6.output"), ] expected = { "data.yml": [ ("1.template", "1.output"), ("2.template", "2.output"), ("3.template", "3.output"), ("4.template", "4.output"), ("5.template", "6.output"), ] } engine = Engine(".", ".") engine.render_to_files(jobs) _do_templates_with_more_shared_data.assert_called_with(expected) if os.path.exists(".moban.hashes"): os.unlink(".moban.hashes")
def test_non_existent_config_directries(): Engine("tests", "abc")
def test_non_existent_tmpl_directries(): Engine("abc", "tests")