Exemple #1
0
 def test_have_data_errors(self):
     h = SmtpSession(None, None, None)
     reply = Reply('250')
     h.HAVE_DATA(reply, None, MessageTooBig())
     self.assertEqual('552', reply.code)
     with self.assertRaises(ValueError):
         h.HAVE_DATA(reply, None, ValueError())
 def test_have_data(self):
     env = Envelope()
     handoff = self.mox.CreateMockAnything()
     handoff(env).AndReturn([(env, 'testid')])
     self.mox.ReplayAll()
     h = SmtpSession(('127.0.0.1', 0), None, handoff)
     h.envelope = env
     reply = Reply('250')
     h.HAVE_DATA(reply, b'', None)
     self.assertEqual('250', reply.code)
     self.assertEqual('2.6.0 Message accepted for delivery', reply.message)
Exemple #3
0
 def test_have_data_queueerror(self):
     env = Envelope()
     handoff = self.mox.CreateMockAnything()
     handoff(env).AndReturn([(env, QueueError())])
     self.mox.ReplayAll()
     h = SmtpSession(('127.0.0.1', 0), None, handoff)
     h.envelope = env
     reply = Reply('250')
     h.HAVE_DATA(reply, b'', None)
     self.assertEqual('451', reply.code)
     self.assertEqual('4.3.0 Error queuing message', reply.message)
Exemple #4
0
 def test_have_data(self):
     class PtrLookup(object):
         def finish(self, *args):
             return 'localhost'
     env = Envelope()
     handoff = self.mox.CreateMockAnything()
     handoff(env).AndReturn([(env, 'testid')])
     self.mox.ReplayAll()
     h = SmtpSession(('127.0.0.1', 0), None, handoff)
     h.envelope = env
     h._ptr_lookup = PtrLookup()
     reply = Reply('250')
     h.HAVE_DATA(reply, b'', None)
     self.assertEqual('250', reply.code)
     self.assertEqual('2.6.0 Message accepted for delivery', reply.message)
     self.assertEqual('localhost', env.client['host'])