Coverage for src/couchers/email/dev.py: 100%
9 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-11-04 02:51 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2024-11-04 02:51 +0000
1import logging
3from couchers.crypto import random_hex
4from couchers.models import Email
6logger = logging.getLogger(__name__)
9def print_dev_email(sender_name, sender_email, recipient, subject, plain, html, list_unsubscribe_header, source_data):
10 """
11 Generates a dummy Email object and prints the plain email contents to the logger
13 This allows developing easier by not having to spin up any email infrastructure, and it spits out login links, etc.
15 Returns a models.Email object that can be straight away added to the database.
16 """
17 message_id = random_hex()
19 logger.info("Dev email:")
20 logger.info(plain)
22 return Email(
23 id=message_id,
24 sender_name=sender_name,
25 sender_email=sender_email,
26 recipient=recipient,
27 subject=subject,
28 plain=plain,
29 html=html,
30 list_unsubscribe_header=list_unsubscribe_header,
31 source_data=source_data,
32 )