def test_attempt(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndReturn((0, '', '')) self.mox.ReplayAll() m.attempt(env, 0)
def test_attempt(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndReturn((0, '', '')) self.mox.ReplayAll() m.attempt(env, 0)
def test_attempt(self): env = Envelope() m = PipeRelay(["relaytest"]) self.mox.StubOutWithMock(m, "_exec_process") m._exec_process(env).AndReturn((0, "", "")) self.mox.ReplayAll() m.attempt(env, 0)
def test_attempt_permanentfail(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndReturn((13, '5.0.0 permanent failure', '')) self.mox.ReplayAll() with self.assertRaises(PermanentRelayError): m.attempt(env, 0)
def test_attempt_timeout(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndRaise(Timeout) self.mox.ReplayAll() with self.assertRaises(TransientRelayError): m.attempt(env, 0)
def test_attempt_permanentfail(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndReturn((13, '5.0.0 permanent failure', '')) self.mox.ReplayAll() with assert_raises(PermanentRelayError): m.attempt(env, 0)
def test_attempt_timeout(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndRaise(Timeout) self.mox.ReplayAll() with assert_raises(TransientRelayError): m.attempt(env, 0)
def test_attempt_transientfail(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndReturn((1337, 'transient failure', '')) self.mox.ReplayAll() with assert_raises(TransientRelayError): m.attempt(env, 0)
def test_attempt_transientfail(self): env = Envelope() m = PipeRelay(['relaytest']) self.mox.StubOutWithMock(m, '_exec_process') m._exec_process(env).AndReturn((1337, 'transient failure', '')) self.mox.ReplayAll() with self.assertRaises(TransientRelayError): m.attempt(env, 0)
def test_attempt_permanentfail(self): env = Envelope() m = PipeRelay(["relaytest"]) self.mox.StubOutWithMock(m, "_exec_process") m._exec_process(env).AndReturn((13, "5.0.0 permanent failure", "")) self.mox.ReplayAll() with self.assertRaises(PermanentRelayError): 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') self._mock_popen('*****@*****.**', 0, '') self._mock_popen('*****@*****.**', 1337, 'transient') self._mock_popen('*****@*****.**', 1337, '5.0.0 permanent') subprocess.Popen(['relaytest', '-f', '*****@*****.**', '*****@*****.**'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).AndRaise(Timeout) self.mox.ReplayAll() m = PipeRelay(['relaytest', '-f', '{sender}', '{recipient}']) results = m.attempt(env, 0) self.assertEqual(4, len(results)) self.assertEqual(None, results['*****@*****.**']) self.assertIsInstance(results['*****@*****.**'], TransientRelayError) self.assertEqual('transient', str(results['*****@*****.**'])) self.assertEqual('450', results['*****@*****.**'].reply.code) self.assertIsInstance(results['*****@*****.**'], PermanentRelayError) self.assertEqual('5.0.0 permanent', str(results['*****@*****.**'])) self.assertEqual('550', results['*****@*****.**'].reply.code) self.assertIsInstance(results['*****@*****.**'], TransientRelayError) self.assertEqual('Delivery timed out', str(results['*****@*****.**'])) self.assertEqual('450', results['*****@*****.**'].reply.code)