gmirator/tests/test_generate.py
2023-09-09 14:07:55 +02:00

37 lines
1.2 KiB
Python

import re
from gmirator.generate import (
process_file,
process_list,
process_inline,
repl_url,
repl_heading
)
def test_process_file():
pass
def test_process_list():
test_str = "this is a line outside a list"
assert process_list(test_str, True) == ("</ul>\n\n", False)
assert process_list(test_str, False) == (test_str, False)
test_str = "* this is a list item"
assert process_list(test_str, True) == ("<li>this is a list item</li>", True)
assert process_list(test_str, False) == ("<ul>\n<li>this is a list item</li>", True)
pass
def test_process_inline():
assert process_inline("*Hello* ~~world~~!") == "<em>Hello</em> <s>world</s>!"
def test_repl_url_external_gmi_url():
external_url = "=> gemini://domain/gempage.gmi\n"
new_url = re.sub(r'^=> (?P<url>[^ ]*) ?(?P<text>.*)\n', repl_url, external_url)
assert new_url == '<a href="gemini://domain/gempage.gmi">=> gemini://domain/gempage.gmi</a><br>\n'
def test_repl_url_internal_gmi_url():
external_url = "=> /gempage.gmi title\n"
new_url = re.sub(r'^=> (?P<url>[^ ]*) ?(?P<text>.*)\n', repl_url, external_url)
assert new_url == '<a href="/gempage.html">=> title</a><br>\n'
def test_repl_heading():
pass