Exemplo n.º 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"
Exemplo n.º 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"
Exemplo n.º 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"
Exemplo n.º 4
0
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
Exemplo n.º 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"
Exemplo n.º 6
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")

    title = b"\xc3\xb8".decode("utf8")
    output = cli.render(path, {"title": title}, [])
    assert output == title
    assert type(output) == cli.text_type
Exemplo n.º 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
Exemplo n.º 8
0
def relative_path_test():
    path = "./files/template.j2"

    output = cli.render(path, {"title": "Test"})
    assert output == "Test"
Exemplo n.º 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"