mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 12:28:06 +00:00
create a wwwdev.sh entry point for helping live web design/development (#92)
* create a wwwdev.sh entry point for developing the web part * rename script * fix README * add a note * don't depend on deltachat python package * avoid bailing out on jinja2 errors, and provide file-url for instant clickability * in webdev mode make page auto-refresh every 3 seconds
This commit is contained in:
@@ -1,19 +1,11 @@
|
||||
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 +22,26 @@ 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"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user