def test_ptr_lookup(self):
     self.mox.StubOutWithMock(resolver, 'query')
     resolver.query(IgnoreArg(), 'PTR').AndRaise(DNSException)
     resolver.query(IgnoreArg(), 'PTR').AndReturn(['example.com'])
     self.mox.ReplayAll()
     h = SmtpSession(('1.2.3.4', None), None, None)
     with self.assertRaises(DNSException):
         h._ptr_lookup()
     self.assertIsNone(h.reverse_address)
     h._ptr_lookup()
     self.assertEqual('example.com', h.reverse_address)
Пример #2
0
 def test_have_data(self):
     class PtrLookup(object):
         def finish(self, *args):
             return 'localhost'
     env = Envelope()
     handoff = self.mox.CreateMockAnything()
     handoff(env).AndReturn([(env, 'testid')])
     self.mox.ReplayAll()
     h = SmtpSession(('127.0.0.1', 0), None, handoff)
     h.envelope = env
     h._ptr_lookup = PtrLookup()
     reply = Reply('250')
     h.HAVE_DATA(reply, b'', None)
     self.assertEqual('250', reply.code)
     self.assertEqual('2.6.0 Message accepted for delivery', reply.message)
     self.assertEqual('localhost', env.client['host'])
Пример #3
0
 def test_have_data(self):
     class PtrLookup(object):
         def finish(self, *args):
             return 'localhost'
     env = Envelope()
     handoff = self.mox.CreateMockAnything()
     handoff(env).AndReturn([(env, 'testid')])
     self.mox.ReplayAll()
     h = SmtpSession(('127.0.0.1', 0), None, handoff)
     h.envelope = env
     h._ptr_lookup = PtrLookup()
     reply = Reply('250')
     h.HAVE_DATA(reply, b'', None)
     self.assertEqual('250', reply.code)
     self.assertEqual('2.6.0 Message accepted for delivery', reply.message)
     self.assertEqual('localhost', env.client['host'])