def test_disconnect_failure(self):
     self.sock.sendall(b'QUIT\r\n')
     self.sock.recv(IsA(int)).AndRaise(socket_error(None, None))
     self.sock.close()
     self.mox.ReplayAll()
     client = SmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='test')
     client._connect()
     client._disconnect()
Ejemplo n.º 2
0
 def test_run_socket_error(self):
     result = AsyncResult()
     env = Envelope('[email protected]', ['[email protected]'])
     env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
     queue = BlockingDeque()
     queue.append((result, env))
     self.sock.recv(IsA(int)).AndRaise(socket_error(None, None))
     self.sock.sendall(b'QUIT\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'221 Goodbye\r\n')
     self.sock.close()
     self.mox.ReplayAll()
     client = SmtpRelayClient(('addr', 0), queue, socket_creator=self._socket_creator, ehlo_as='there')
     client._run()
     with self.assertRaises(TransientRelayError):
         result.get_nowait()
 def socket_creator(address):
     raise socket_error(None, None)