mirror of
https://github.com/chatmail/relay.git
synced 2026-06-10 05:31:08 +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:
@@ -3,6 +3,7 @@ import json
|
||||
import chatmaild
|
||||
from chatmaild.newemail import create_newemail_dict, print_new_account
|
||||
|
||||
|
||||
def test_create_newemail_dict():
|
||||
ac1 = create_newemail_dict(domain="example.org")
|
||||
assert "@" in ac1["email"]
|
||||
|
||||
+14
-2
@@ -278,13 +278,13 @@ class ChatmailTestProcess:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cmfactory(request, gencreds, tmpdir, data, maildomain):
|
||||
def cmfactory(request, gencreds, tmpdir, maildomain):
|
||||
# cloned from deltachat.testplugin.amfactory
|
||||
pytest.importorskip("deltachat")
|
||||
from deltachat.testplugin import ACFactory
|
||||
|
||||
testproc = ChatmailTestProcess(request.config, maildomain, gencreds)
|
||||
am = ACFactory(request=request, tmpdir=tmpdir, testprocess=testproc, data=data)
|
||||
am = ACFactory(request=request, tmpdir=tmpdir, testprocess=testproc, data=None)
|
||||
|
||||
# nb. a bit hacky
|
||||
# would probably be better if deltachat's test machinery grows native support
|
||||
@@ -326,6 +326,18 @@ class Remote:
|
||||
break
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def lp(request):
|
||||
class LP:
|
||||
def sec(self, msg):
|
||||
print(f"---- {msg} ----")
|
||||
|
||||
def indent(self, msg):
|
||||
print(f" {msg}")
|
||||
|
||||
return LP()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def maildata(request, gencreds):
|
||||
datadir = conftestdir.joinpath("mail-data")
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
from deploy_chatmail.genqr import gen_qr_png_data
|
||||
|
||||
|
||||
|
||||
+22
-14
@@ -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