Beispiel #1
0
def test_markdown():
    path = "./files/md_template.j2"

    output = cli.render(path, {"content": "#Test"}, [], markdown=True)
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')
    assert output == "<h1>Test</h1>\n"
Beispiel #2
0
def test_relative_path():
    path = "./files/template.j2"

    output = cli.render(path, {"title": "Test"}, [])
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')
    assert output == "Test"
Beispiel #3
0
def test_relative_path():
    path = "./files/template.j2"

    output = cli.render(path, {"title": "Test"}, [])
    if isinstance(output, cli.text_type):
        output = output.encode("utf-8")
    assert output == b"Test"
def test_relative_path():
    path = "./files/template.j2"

    title = b"\xc3\xb8".decode("utf8")
    output = cli.render(path, {"title": title}, [])
    assert output == title
    assert type(output) == cli.text_type
Beispiel #5
0
def test_absolute_path():
    absolute_base_path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(absolute_base_path, "files", "template.j2")

    output = cli.render(path, {"title": "Test"}, [])
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')
    assert output == "Test"
def test_absolute_path():
    absolute_base_path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(absolute_base_path, "files", "template.j2")

    title = b"\xc3\xb8".decode("utf8")
    output = cli.render(path, {"title": title}, [])
    assert output == title
    assert type(output) == cli.text_type
Beispiel #7
0
def test_recursive():
    path = "./files/recursive_template.j2"
    data = {'sitename': 'SiteName', 'title': 'Welcome to {{ sitename }}'}
    recursive_result_path = "./files/recursive_template_recursive_result.html"

    output = cli.render(path, data, [], False, True)
    if isinstance(output, cli.binary_type):
        output = output.decode('utf-8')

    with open(recursive_result_path) as f:
        expected_result = f.read()
        assert output == expected_result
Beispiel #8
0
def relative_path_test():
    path = "./files/template.j2"

    output = cli.render(path, {"title": "Test"})
    assert output == "Test"
Beispiel #9
0
def absolute_path_test():
    absolute_base_path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(absolute_base_path, "files", "template.j2")

    output = cli.render(path, {"title": "Test"})
    assert output == "Test"