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

1import logging 

2 

3from couchers.crypto import random_hex 

4from couchers.models import Email 

5 

6logger = logging.getLogger(__name__) 

7 

8 

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 

12 

13 This allows developing easier by not having to spin up any email infrastructure, and it spits out login links, etc. 

14 

15 Returns a models.Email object that can be straight away added to the database. 

16 """ 

17 message_id = random_hex() 

18 

19 logger.info("Dev email:") 

20 logger.info(plain) 

21 

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 )