예제 #1
0
파일: test_template.py 프로젝트: chfw/moban
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.template", "test")]})
    with open("test", "r") as f:
        content = f.read()
        assert content == "hello world ox"
    os.unlink("test")
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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")
예제 #5
0
def test_do_templates_with_more_shared_templates():
    base_dir = os.path.join("tests", "fixtures")
    engine = Engine(base_dir, os.path.join(base_dir, "config"))
    engine._render_with_finding_template_first({
        "a.template": [(os.path.join(base_dir, "child.yaml"),
                        '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')
예제 #6
0
파일: test_template.py 프로젝트: chfw/moban
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)
예제 #7
0
파일: test_template.py 프로젝트: chfw/moban
def test_do_templates_2(_do_templates_with_more_shared_templates):
    jobs = [
        ("1.template", "data1.yml", "1.output"),
        ("1.template", "data2.yml", "2.output"),
        ("1.template", "data3.yml", "3.output"),
        ("1.template", "data4.yml", "4.output"),
        ("1.template", "data5.yml", "6.output"),
    ]
    expected = {
        "1.template": [
            ("data1.yml", "1.output"),
            ("data2.yml", "2.output"),
            ("data3.yml", "3.output"),
            ("data4.yml", "4.output"),
            ("data5.yml", "6.output"),
        ]
    }
    engine = Engine(".", ".")
    engine.render_to_files(jobs)
    _do_templates_with_more_shared_templates.assert_called_with(expected)
예제 #8
0
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")
예제 #9
0
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')
예제 #10
0
def test_non_existent_config_directries():
    Engine("tests", "abc")
예제 #11
0
def test_non_existent_tmpl_directries():
    Engine("abc", "tests")