wcs/tests/test_bounce_processing.py

22 lines
642 B
Python

import email
from wcs.ctl.process_bounce import CmdProcessBounce
def test_normal_email():
msg = email.message_from_string('test')
msg['From'] = 'bar@example.net'
msg['To'] = 'foo@example.net'
addrs = CmdProcessBounce.get_bounce_addrs(msg)
assert addrs is None
def test_bounce_email():
msg = email.message_from_string('test')
msg['From'] = 'bar@example.net'
msg['To'] = 'foo@example.net'
# this is how exim adds failed recipients in its outgoing bounce emails
msg['x-failed-recipients'] = 'baz@example.net'
addrs = CmdProcessBounce.get_bounce_addrs(msg)
assert addrs == ['baz@example.net']