32 lines
754 B
Python
32 lines
754 B
Python
#!/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")
|