from email import message_from_bytes
from email.policy import default
from inkwell import mail_templates
from inkwell.mailer import MailSettings, build_message
LINK = "https://notes.example.test/reset-password?token=abc-123"
def test_every_email_carries_its_link_in_both_parts():
for email in (
mail_templates.password_reset("Inkwell", "a@example.test", LINK),
mail_templates.invite("Inkwell", "Sam", LINK, 7),
):
assert LINK in email.text
assert f'href="{LINK}"' in email.html
def test_text_from_settings_and_people_is_escaped_in_the_html():
email = mail_templates.invite('Ink & "co"', "", LINK, 1)
assert "" in email.text
assert "within a day" in email.text
def test_the_html_fetches_nothing():
"""No remote images or fonts: the app sends with no outbound network, and a remote
image in an email is a tracking pixel."""
html = mail_templates.password_reset("Inkwell", "a@example.test", LINK).html
assert "![]()