Esempio n. 1
0
    def test_bounce_generic_message(self):
        import base64
        from repoze.postoffice.message import Message
        class DummySend(object):
            def __init__(self):
                self.sent = []
            def __call__(self, fromaddr, toaddrs, message):
                self.sent.append((fromaddr, toaddrs, message))

        bounced = Message()
        bounced['To'] = 'Submissions <*****@*****.**>'
        bounced['From'] = 'Chris Rossi <*****@*****.**>'
        bounced['Date'] = 'Last Tuesday'
        queue = self._make_one()
        send = DummySend()
        queue.bounce(bounced, send, 'Bouncer <*****@*****.**>')

        self.assertEqual(len(send.sent), 1)
        fromaddr, toaddrs, message = send.sent[0]
        self.assertEqual(fromaddr, 'Bouncer <*****@*****.**>')
        self.assertEqual(message['From'], 'Bouncer <*****@*****.**>')
        self.assertEqual(toaddrs, ['Chris Rossi <*****@*****.**>'])
        self.assertEqual(message['To'], 'Chris Rossi <*****@*****.**>')
        self.failUnless(message['Subject'].startswith(
            'Your message to Submissions'), message['Subject'])
        self.assertEqual(message['X-Postoffice'], 'Bounced')
        body = base64.b64decode(message.get_payload())
        self.failUnless('has bounced' in body, body)
        self.failUnless('Last Tuesday' in body, body)
Esempio n. 2
0
    def test_bounce_generic_message(self):
        import base64
        from repoze.postoffice.message import Message

        class DummySend(object):
            def __init__(self):
                self.sent = []

            def __call__(self, fromaddr, toaddrs, message):
                self.sent.append((fromaddr, toaddrs, message))

        bounced = Message()
        bounced['To'] = 'Submissions <*****@*****.**>'
        bounced['From'] = 'Chris Rossi <*****@*****.**>'
        bounced['Date'] = 'Last Tuesday'
        queue = self._make_one()
        send = DummySend()
        queue.bounce(bounced, send, 'Bouncer <*****@*****.**>')

        self.assertEqual(len(send.sent), 1)
        fromaddr, toaddrs, message = send.sent[0]
        self.assertEqual(fromaddr, 'Bouncer <*****@*****.**>')
        self.assertEqual(message['From'], 'Bouncer <*****@*****.**>')
        self.assertEqual(toaddrs, ['Chris Rossi <*****@*****.**>'])
        self.assertEqual(message['To'], 'Chris Rossi <*****@*****.**>')
        self.failUnless(
            message['Subject'].startswith('Your message to Submissions'),
            message['Subject'])
        self.assertEqual(message['X-Postoffice'], 'Bounced')
        body = base64.b64decode(message.get_payload())
        self.failUnless('has bounced' in body, body)
        self.failUnless('Last Tuesday' in body, body)
Esempio n. 3
0
    def test_bounce_custom_message(self):
        import base64
        from repoze.postoffice.message import Message
        class DummySend(object):
            def __init__(self):
                self.sent = []
            def __call__(self, fromaddr, toaddrs, message):
                self.sent.append((fromaddr, toaddrs, message))

        bounced = Message()
        bounced['To'] = 'Submissions <*****@*****.**>'
        bounced['From'] = 'Chris Rossi <*****@*****.**>'
        queue = self._make_one()
        send = DummySend()
        bounce_message = Message()
        bounce_message.set_payload('TEST')
        queue.bounce(bounced, send, 'Bouncer <*****@*****.**>',
                     bounce_message=bounce_message)

        self.assertEqual(len(send.sent), 1)
        fromaddr, toaddrs, message = send.sent[0]
        self.assertEqual(fromaddr, 'Bouncer <*****@*****.**>')
        self.assertEqual(toaddrs, ['Chris Rossi <*****@*****.**>'])
        self.assertEqual(message.get_payload(), 'TEST')
        self.assertEqual(message['X-Postoffice'], 'Bounced')
Esempio n. 4
0
    def test_bounce_custom_message(self):
        import base64
        from repoze.postoffice.message import Message

        class DummySend(object):
            def __init__(self):
                self.sent = []

            def __call__(self, fromaddr, toaddrs, message):
                self.sent.append((fromaddr, toaddrs, message))

        bounced = Message()
        bounced['To'] = 'Submissions <*****@*****.**>'
        bounced['From'] = 'Chris Rossi <*****@*****.**>'
        queue = self._make_one()
        send = DummySend()
        bounce_message = Message()
        bounce_message.set_payload('TEST')
        queue.bounce(bounced,
                     send,
                     'Bouncer <*****@*****.**>',
                     bounce_message=bounce_message)

        self.assertEqual(len(send.sent), 1)
        fromaddr, toaddrs, message = send.sent[0]
        self.assertEqual(fromaddr, 'Bouncer <*****@*****.**>')
        self.assertEqual(toaddrs, ['Chris Rossi <*****@*****.**>'])
        self.assertEqual(message.get_payload(), 'TEST')
        self.assertEqual(message['X-Postoffice'], 'Bounced')