def test_attempt_timeout(self):
     self.mox.StubOutWithMock(subprocess, 'Popen')
     env = Envelope('*****@*****.**', ['*****@*****.**'])
     env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
     subprocess.Popen(['maildrop', '-f', '*****@*****.**'],
                      stdin=subprocess.PIPE,
                      stdout=subprocess.PIPE,
                      stderr=subprocess.PIPE).AndRaise(Timeout)
     self.mox.ReplayAll()
     m = MaildropRelay()
     with self.assertRaises(TransientRelayError):
         m.attempt(env, 0)
 def test_attempt_timeout(self):
     self.mox.StubOutWithMock(subprocess, 'Popen')
     env = Envelope('*****@*****.**', ['*****@*****.**'])
     env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
     subprocess.Popen(['maildrop', '-f', '*****@*****.**'],
                      stdin=subprocess.PIPE,
                      stdout=subprocess.PIPE,
                      stderr=subprocess.PIPE).AndRaise(Timeout)
     self.mox.ReplayAll()
     m = MaildropRelay()
     with self.assertRaises(TransientRelayError):
         m.attempt(env, 0)
 def test_attempt(self):
     self.mox.StubOutWithMock(subprocess, 'Popen')
     env = Envelope('*****@*****.**', ['*****@*****.**'])
     env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
     pmock = self.mox.CreateMock(subprocess.Popen)
     subprocess.Popen(['maildrop', '-f', '*****@*****.**'],
                      stdin=subprocess.PIPE,
                      stdout=subprocess.PIPE,
                      stderr=subprocess.PIPE).AndReturn(pmock)
     pmock.communicate(b'From: [email protected]\r\n\r\ntest test\r\n').AndReturn(('', ''))
     pmock.pid = -1
     pmock.returncode = 0
     self.mox.ReplayAll()
     m = MaildropRelay()
     result = m.attempt(env, 0)
     self.assertEqual(None, result)