Example #1
0
 def test_wait_channel(self):
     DNSResolver._channel = channel = self.mox.CreateMockAnything()
     poll = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(select, 'poll')
     select.poll().AndReturn(poll)
     channel.getsock().AndReturn(([1, 2], [2, 3]))
     channel.timeout().AndReturn(1.0)
     poll.register(1, select.POLLIN)
     poll.register(2, select.POLLIN | select.POLLOUT)
     poll.register(3, select.POLLOUT)
     poll.poll(1.0).AndReturn([(1, select.POLLIN), (3, select.POLLOUT)])
     channel.process_fd(1, pycares.ARES_SOCKET_BAD)
     channel.process_fd(pycares.ARES_SOCKET_BAD, 3)
     channel.getsock().AndReturn(([1, 3], [4]))
     channel.timeout().AndReturn(1.0)
     poll.register(3, select.POLLIN)
     poll.register(4, select.POLLOUT)
     poll.unregister(2)
     poll.poll(1.0).AndReturn([])
     channel.getsock().AndReturn(([1, 3], [4]))
     channel.timeout().AndReturn(None)
     channel.process_fd(pycares.ARES_SOCKET_BAD, pycares.ARES_SOCKET_BAD)
     channel.getsock().AndReturn(([], []))
     poll.unregister(1)
     poll.unregister(3)
     poll.unregister(4)
     self.mox.ReplayAll()
     DNSResolver._wait_channel()
 def test_wait_channel_error(self):
     DNSResolver._channel = channel = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(select, 'select')
     channel.getsock().AndReturn(('read', 'write'))
     channel.timeout().AndReturn(1.0)
     select.select('read', 'write', [], 1.0).AndRaise(ValueError(13))
     channel.cancel()
     self.mox.ReplayAll()
     with self.assertRaises(ValueError):
         DNSResolver._wait_channel()
     self.assertIsNone(DNSResolver._channel)
Example #3
0
 def test_wait_channel_error(self):
     DNSResolver._channel = channel = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(select, 'select')
     channel.getsock().AndReturn(('read', 'write'))
     channel.timeout().AndReturn(1.0)
     select.select('read', 'write', [], 1.0).AndRaise(ValueError(13))
     channel.cancel()
     self.mox.ReplayAll()
     with self.assertRaises(ValueError):
         DNSResolver._wait_channel()
     self.assertIsNone(DNSResolver._channel)
Example #4
0
 def test_wait_channel_error(self):
     DNSResolver._channel = channel = self.mox.CreateMockAnything()
     poll = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(select, 'poll')
     select.poll().AndReturn(poll)
     channel.getsock().AndReturn(([1], []))
     channel.timeout().AndReturn(1.0)
     poll.register(1, select.POLLIN).AndReturn(None)
     poll.poll(1.0).AndRaise(ValueError(13))
     channel.cancel()
     self.mox.ReplayAll()
     with self.assertRaises(ValueError):
         DNSResolver._wait_channel()
     self.assertIsNone(DNSResolver._channel)
 def test_wait_channel(self):
     DNSResolver._channel = channel = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(select, 'select')
     channel.getsock().AndReturn(('read', 'write'))
     channel.timeout().AndReturn(1.0)
     select.select('read', 'write', [], 1.0).AndReturn(
         ([1, 2, 3], [4, 5, 6], None))
     for fd in [1, 2, 3]:
         channel.process_fd(fd, pycares.ARES_SOCKET_BAD)
     for fd in [4, 5, 6]:
         channel.process_fd(pycares.ARES_SOCKET_BAD, fd)
     channel.getsock().AndReturn(('read', 'write'))
     channel.timeout().AndReturn(None)
     channel.process_fd(pycares.ARES_SOCKET_BAD, pycares.ARES_SOCKET_BAD)
     channel.getsock().AndReturn((None, None))
     self.mox.ReplayAll()
     DNSResolver._wait_channel()
Example #6
0
 def test_wait_channel(self):
     DNSResolver._channel = channel = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(select, 'select')
     channel.getsock().AndReturn(('read', 'write'))
     channel.timeout().AndReturn(1.0)
     select.select('read', 'write', [], 1.0).AndReturn(
         ([1, 2, 3], [4, 5, 6], None))
     for fd in [1, 2, 3]:
         channel.process_fd(fd, pycares.ARES_SOCKET_BAD)
     for fd in [4, 5, 6]:
         channel.process_fd(pycares.ARES_SOCKET_BAD, fd)
     channel.getsock().AndReturn(('read', 'write'))
     channel.timeout().AndReturn(None)
     channel.process_fd(pycares.ARES_SOCKET_BAD, pycares.ARES_SOCKET_BAD)
     channel.getsock().AndReturn((None, None))
     self.mox.ReplayAll()
     DNSResolver._wait_channel()