from gmirator.generate import (
make_paragraph,
process_heading,
process_list,
process_inline,
process_url
)
############################
### generate gmi section ###
############################
def test_make_footer():
pass
def test_find_title_date():
pass
#############################
### generate html section ###
#############################
def test_process_list_legit_item():
test_str = "* this is a list item"
assert process_list(test_str, True) == (f"
{test_str[2:]}", True)
assert process_list(test_str, False) == (f"\n- {test_str[2:]}
", True)
def test_process_list_not_list_items():
test_str = "this is a line outside a list"
assert process_list(test_str, True) == (f"
\n\n{test_str}", False)
assert process_list(test_str, False) == (test_str, False)
test_str = "*this is NOT a list item*"
assert process_list(test_str, True) == (f"\n\n{test_str}", False)
assert process_list(test_str, False) == (f"{test_str}", False)
def test_process_list_empty_line():
assert process_list("", True) == ("\n\n", False)
assert process_list("", False) == ("", False)
def test_process_inline():
assert process_inline("*Hello* ~~world~~!") == "Hello world!"
def test_process_url_external_gmi_url():
external_url = "=> gemini://domain/gempage.gmi\n"
new_url = process_url(external_url)
assert new_url == '=> gemini://domain/gempage.gmi
\n'
def test_process_url_internal_gmi_url():
internal_url = "=> /gempage.gmi title\n"
new_url = process_url(internal_url)
assert new_url == '=> title
\n'
def test_process_heading():
line = "# this is h1 title"
html_h1 = process_heading(line)
line = "## this is h2 title"
html_h2 = process_heading(line)
line = "### this is h3 title"
html_h3 = process_heading(line)
assert html_h1 == "# this is h1 title
"
assert html_h2 == "## this is h2 title
"
assert html_h3 == "### this is h3 title
"
def test_process_heading_h4():
line = "#### this is h4 title"
html_h4 = process_heading(line)
assert html_h4 == "#### this is h4 title
"
def test_make_paragraph():
line = "hello world!"
assert make_paragraph(line) == "hello world!
\n"
line = "*hello world!*"
assert make_paragraph(line) == "*hello world!*
\n"