Coverage for src/couchers/email/dev.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

9 statements  

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): 

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 )