mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
fix various test setups
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from chatmaild.config import read_config
|
||||
import chatmaild.config
|
||||
|
||||
|
||||
def test_read_config_basic(make_config):
|
||||
|
||||
@@ -5,8 +5,6 @@ from chatmaild.filtermail import (
|
||||
check_mdn,
|
||||
)
|
||||
|
||||
from chatmaild.config import read_config
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -17,8 +15,8 @@ def maildomain():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def handler(create_ini, maildomain):
|
||||
config = read_config(create_ini(), maildomain)
|
||||
def handler(make_config, maildomain):
|
||||
config = make_config(maildomain)
|
||||
return BeforeQueueHandler(config)
|
||||
|
||||
|
||||
@@ -101,9 +99,8 @@ def test_send_rate_limiter():
|
||||
def test_excempt_privacy(maildata, gencreds, handler):
|
||||
from_addr = gencreds()[0]
|
||||
to_addr = "privacy@testrun.org"
|
||||
false_to = "privacy@tstrn.org"
|
||||
false_to2 = "prvcy@testrun.org"
|
||||
assert to_addr in handler.config.passthrough_recipients
|
||||
handler.config.passthrough_recipients = [to_addr]
|
||||
false_to = "privacy@something.org"
|
||||
|
||||
msg = maildata("plain.eml", from_addr, to_addr)
|
||||
|
||||
@@ -117,7 +114,7 @@ def test_excempt_privacy(maildata, gencreds, handler):
|
||||
|
||||
class env2:
|
||||
mail_from = from_addr
|
||||
rcpt_tos = [to_addr, false_to, false_to2]
|
||||
rcpt_tos = [to_addr, false_to]
|
||||
content = msg.as_bytes()
|
||||
|
||||
assert "500" in handler.check_DATA(envelope=env2)
|
||||
|
||||
@@ -5,44 +5,12 @@ from deploy_chatmail.www import build_webpages
|
||||
from chatmaild.config import read_config
|
||||
|
||||
|
||||
def make_config(create_ini, domain="example.org"):
|
||||
inipath = create_ini(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
[params]
|
||||
max_user_send_per_minute = 60
|
||||
filtermail_smtp_port = 10080
|
||||
postfix_reinject_port = 10025
|
||||
passthrough_recipients =
|
||||
|
||||
[privacy:{domain}]
|
||||
domain = example.org
|
||||
privacy_postal =
|
||||
address-line1
|
||||
address-line2
|
||||
|
||||
privacy_mail = privacy@{domain}
|
||||
|
||||
privacy_pdo =
|
||||
address-line3
|
||||
"""
|
||||
)
|
||||
)
|
||||
return read_config(inipath, domain)
|
||||
|
||||
|
||||
def test_build_webpages(tmp_path, create_ini):
|
||||
def test_build_webpages(tmp_path, make_config):
|
||||
pkgroot = importlib.resources.files("deploy_chatmail")
|
||||
src_dir = pkgroot.joinpath("../../../www/src").resolve()
|
||||
assert src_dir.exists(), src_dir
|
||||
config = make_config(create_ini, "example.org")
|
||||
config = make_config("chat.example.org")
|
||||
build_dir = tmp_path.joinpath("build")
|
||||
build_webpages(src_dir, build_dir, config)
|
||||
|
||||
|
||||
def test_get_settings(tmp_path, create_ini):
|
||||
config = make_config(create_ini, "example.org")
|
||||
assert config.privacy_postal == "address-line1\naddress-line2"
|
||||
assert config.privacy_mail == "privacy@example.org"
|
||||
assert config.privacy_pdo == "address-line3"
|
||||
assert config.mailname == "example.org"
|
||||
assert len([x for x in build_dir.iterdir() if x.suffix == '.html']) >= 3
|
||||
|
||||
Reference in New Issue
Block a user