def test_attempt(self):
     env = Envelope()
     m = MaildropRelay()
     self.mox.StubOutWithMock(m, "_exec_maildrop")
     m._exec_maildrop(env).AndReturn((0, None))
     self.mox.ReplayAll()
     m.attempt(env, 0)
 def test_attempt_permanentfail(self):
     env = Envelope()
     m = MaildropRelay()
     self.mox.StubOutWithMock(m, "_exec_maildrop")
     m._exec_maildrop(env).AndReturn((13, "permanent failure"))
     self.mox.ReplayAll()
     with self.assertRaises(PermanentRelayError):
         m.attempt(env, 0)
 def test_attempt_timeout(self):
     env = Envelope()
     m = MaildropRelay()
     self.mox.StubOutWithMock(m, "_exec_maildrop")
     m._exec_maildrop(env).AndRaise(Timeout)
     self.mox.ReplayAll()
     with self.assertRaises(TransientRelayError):
         m.attempt(env, 0)
 def test_attempt_transientfail(self):
     env = Envelope()
     m = MaildropRelay()
     self.mox.StubOutWithMock(m, "_exec_maildrop")
     m._exec_maildrop(env).AndReturn((MaildropRelay.EX_TEMPFAIL, "transient failure"))
     self.mox.ReplayAll()
     with self.assertRaises(TransientRelayError):
         m.attempt(env, 0)