quill: draft-email.py — template composer with inline verification
This commit is contained in:
1 parent
849ac67e5e
commit
319ad18dfe
1 file changed
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Draft email: compose from template, validate, verify formatting."""
|
||||
import sys, pathlib
|
||||
|
||||
TEMPLATE = """\
|
||||
Subject: Draft — {title}
|
||||
|
||||
Hi {name},
|
||||
|
||||
This is a quick draft for: {title}.
|
||||
|
||||
{body}
|
||||
|
||||
— DraftBot
|
||||
"""
|
||||
|
||||
def compose(title="Hello World", name="Team", body="Auto-generated draft."):
|
||||
return TEMPLATE.format(title=title, name=name, body=body)
|
||||
|
||||
def verify(msg):
|
||||
assert "Subject: Draft — " in msg, "missing Subject header"
|
||||
assert "Hi Team" in msg, "missing greeting"
|
||||
assert "Auto-generated draft." in msg, "missing body"
|
||||
assert msg.endswith("— DraftBot\n"), "missing signature"
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
out = compose()
|
||||
print(out)
|
||||
assert verify(out)
|
||||
print("CHECK_PASSED")
|
||||
Reference in new issue
Block a user