23 lines
658 B
Python
23 lines
658 B
Python
import email
|
|
import StringIO
|
|
|
|
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']
|