def test_rcptto(self):
     self.sock.sendall(b'RCPT TO:<test>\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250 2.0.0 Ok\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     reply = client.rcptto('test')
     self.assertEqual('250', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
     self.assertEqual(b'RCPT', reply.command)
     self.assertEqual([('test', reply)], client.rcpttos)
 def test_rcptto(self):
     self.sock.sendall(b"RCPT TO:<test>\r\n")
     self.sock.recv(IsA(int)).AndReturn(b"250 2.0.0 Ok\r\n")
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     reply = client.rcptto("test")
     self.assertEqual("250", reply.code)
     self.assertEqual("2.0.0 Ok", reply.message)
     self.assertEqual(b"RCPT", reply.command)
     self.assertEqual([("test", reply)], client.rcpttos)
Beispiel #3
0
 def test_rcptto(self):
     self.sock.sendall(b'RCPT TO:<test>\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250 2.0.0 Ok\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     reply = client.rcptto('test')
     self.assertEqual('250', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
     self.assertEqual(b'RCPT', reply.command)
     self.assertEqual([('test', reply)], client.rcpttos)
 def test_rset(self):
     self.sock.sendall(b"RSET\r\n")
     self.sock.recv(IsA(int)).AndReturn(b"250 Ok\r\n")
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     client.rcpttos = "testing"
     reply = client.rset()
     self.assertEqual("250", reply.code)
     self.assertEqual("2.0.0 Ok", reply.message)
     self.assertEqual(b"RSET", reply.command)
     self.assertEqual([], client.rcpttos)
Beispiel #5
0
 def test_rset(self):
     self.sock.sendall(b'RSET\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     client.rcpttos = 'testing'
     reply = client.rset()
     self.assertEqual('250', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
     self.assertEqual(b'RSET', reply.command)
     self.assertEqual([], client.rcpttos)
 def test_rset(self):
     self.sock.sendall(b'RSET\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     client.rcpttos = 'testing'
     reply = client.rset()
     self.assertEqual('250', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
     self.assertEqual(b'RSET', reply.command)
     self.assertEqual([], client.rcpttos)
 def test_lhlo(self):
     self.sock.sendall(b"LHLO there\r\n")
     self.sock.recv(IsA(int)).AndReturn(b"250-Hello there\r\n250-TEST arg\r\n")
     self.sock.recv(IsA(int)).AndReturn(b"250 EXTEN\r\n")
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     reply = client.lhlo("there")
     self.assertEqual("250", reply.code)
     self.assertEqual("Hello there", reply.message)
     self.assertEqual(b"LHLO", reply.command)
     self.assertTrue("TEST" in client.extensions)
     self.assertTrue("EXTEN" in client.extensions)
     self.assertEqual("arg", client.extensions.getparam("TEST"))
 def test_lhlo(self):
     self.sock.sendall(b'LHLO there\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250-Hello there\r\n250-TEST arg\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250 EXTEN\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     reply = client.lhlo('there')
     self.assertEqual('250', reply.code)
     self.assertEqual('Hello there', reply.message)
     self.assertEqual(b'LHLO', reply.command)
     self.assertTrue('TEST' in client.extensions)
     self.assertTrue('EXTEN' in client.extensions)
     self.assertEqual('arg', client.extensions.getparam('TEST'))
Beispiel #9
0
 def test_lhlo(self):
     self.sock.sendall('LHLO there\r\n')
     self.sock.recv(IsA(int)).AndReturn('250-Hello there\r\n250-TEST arg\r\n')
     self.sock.recv(IsA(int)).AndReturn('250 EXTEN\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     reply = client.lhlo('there')
     self.assertEqual('250', reply.code)
     self.assertEqual('Hello there', reply.message)
     self.assertEqual('LHLO', reply.command)
     self.assertTrue('TEST' in client.extensions)
     self.assertTrue('EXTEN' in client.extensions)
     self.assertEqual('arg', client.extensions.getparam('TEST'))
 def test_send_empty_data(self):
     self.sock.sendall(b".\r\n")
     self.sock.recv(IsA(int)).AndReturn(b"250 2.0.0 Ok\r\n" b"550 5.0.0 Not Ok\r\n")
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     client.rcpttos = [("test1", Reply("250")), ("test2", Reply("250")), ("test3", Reply("550"))]
     replies = client.send_empty_data()
     self.assertEqual(2, len(replies))
     self.assertEqual("test1", replies[0][0])
     self.assertEqual("250", replies[0][1].code)
     self.assertEqual("2.0.0 Ok", replies[0][1].message)
     self.assertEqual(b"[SEND_DATA]", replies[0][1].command)
     self.assertEqual("test2", replies[1][0])
     self.assertEqual("550", replies[1][1].code)
     self.assertEqual("5.0.0 Not Ok", replies[1][1].message)
     self.assertEqual(b"[SEND_DATA]", replies[1][1].command)
Beispiel #11
0
 def test_send_empty_data(self):
     self.sock.sendall(b'.\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250 2.0.0 Ok\r\n'
                                        b'550 5.0.0 Not Ok\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     client.rcpttos = [('test1', Reply('250')), ('test2', Reply('250')),
                       ('test3', Reply('550'))]
     replies = client.send_empty_data()
     self.assertEqual(2, len(replies))
     self.assertEqual('test1', replies[0][0])
     self.assertEqual('250', replies[0][1].code)
     self.assertEqual('2.0.0 Ok', replies[0][1].message)
     self.assertEqual(b'[SEND_DATA]', replies[0][1].command)
     self.assertEqual('test2', replies[1][0])
     self.assertEqual('550', replies[1][1].code)
     self.assertEqual('5.0.0 Not Ok', replies[1][1].message)
     self.assertEqual(b'[SEND_DATA]', replies[1][1].command)
 def test_send_empty_data(self):
     self.sock.sendall(b'.\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'250 2.0.0 Ok\r\n'
                                        b'550 5.0.0 Not Ok\r\n')
     self.mox.ReplayAll()
     client = LmtpClient(self.sock)
     client.rcpttos = [('test1', Reply('250')),
                       ('test2', Reply('250')),
                       ('test3', Reply('550'))]
     replies = client.send_empty_data()
     self.assertEqual(2, len(replies))
     self.assertEqual('test1', replies[0][0])
     self.assertEqual('250', replies[0][1].code)
     self.assertEqual('2.0.0 Ok', replies[0][1].message)
     self.assertEqual(b'[SEND_DATA]', replies[0][1].command)
     self.assertEqual('test2', replies[1][0])
     self.assertEqual('550', replies[1][1].code)
     self.assertEqual('5.0.0 Not Ok', replies[1][1].message)
     self.assertEqual(b'[SEND_DATA]', replies[1][1].command)
Beispiel #13
0
 def test_helo_invalid(self):
     client = LmtpClient(self.sock)
     self.assertRaises(NotImplementedError, client.helo, 'there')