create a wwwdev.sh entry point for developing the web part

This commit is contained in:
holger krekel
2023-12-07 14:46:52 +01:00
parent 8cb77d3b98
commit 858e079418
16 changed files with 157 additions and 88 deletions

View File

@@ -1,19 +1,10 @@
import textwrap
import importlib.resources
from deploy_chatmail import build_htmlj2_from_markdown, get_ini_settings
from deploy_chatmail.www import build_webpages
from deploy_chatmail import get_ini_settings
def test_markdown(tmp_path):
path = tmp_path.joinpath("privacy.md")
path.write_text("# privacy policy")
build_htmlj2_from_markdown(path)
output = path.with_name("privacy.html.j2")
assert output.exists()
print(output.read_text())
def test_get_settings(tmp_path):
inipath = tmp_path.joinpath("chatmail.ini")
def create_ini(inipath):
inipath.write_text(
textwrap.dedent(
"""\
@@ -30,10 +21,25 @@ def test_get_settings(tmp_path):
"""
)
)
def test_build_webpages(tmp_path):
pkgroot = importlib.resources.files("deploy_chatmail")
src_dir = pkgroot.joinpath("../../../www/src").resolve()
assert src_dir.exists(), src_dir
inipath = tmp_path.joinpath("chatmail.ini")
create_ini(inipath)
config = get_ini_settings("example.org", inipath)
build_dir = tmp_path.joinpath("build")
build_webpages(src_dir, build_dir, config)
def test_get_settings(tmp_path):
inipath = tmp_path.joinpath("chatmail.ini")
create_ini(inipath)
d = get_ini_settings("x.testrun.org", inipath)
assert d["privacy_postal"] == "address-line1\naddress-line2"
assert d["privacy_mail"] == "privacy@example.org"
assert d["privacy_pdo"] == "address-line3"
assert d["mail_domain"] == "x.testrun.org"