def test_jinja_template_advanced():
    """
    Ensure multi-Jinja sanity, as well as nested files.
    """
    with tmpdir() as tmp:
        jt1 = JinjaTemplate("tests/resources/templates/jinja1")
        jt2 = JinjaTemplate("tests/resources/templates/jinja2")

        context = {"foo": "foo1", "kruft": "kruft1", "plop": "plop1", "no": "no", "go": "go"}

        jt1.set_context(context)
        jt2.set_context(context)
        jt1.render(tmp)
        jt2.render(tmp)

        files = {
            "literal": "{{literal}}",
            "really/nested/directory/with/a/file/foo": context["foo"],
            "kruft": context["kruft"],
            "foo": context["foo"],
            "nogo": "%s %s" % (context["no"], context["go"]),
            "plop": context["plop"],
        }

        with cd(tmp):
            for f in files:
                assert_content(f, files[f])
def test_jinja2_context():
    tpl = JinjaTemplate("tests/resources/templates/jinja1")
    with tmpdir() as tmp:
        try:
            tpl.render(tmp)
            assert True is False
        except ValueError:
            pass
def test_jinja_template_basic():
    """
    Ensure basic Jinja sanity.
    """
    with tmpdir() as tmp:
        jt1 = JinjaTemplate("tests/resources/templates/jinja1")

        context = {"foo": "foo1", "kruft": "kruft1", "plop": "plop1"}

        jt1.set_context(context)
        jt1.render(tmp)

        with cd(tmp):
            for x in context:
                if not os.path.exists(x):
                    assert os.path.exists(x)

            for entry in context:
                assert_content(entry, context[entry])