def testAuthProcessInput(self): fd = MockFd(1) self.server._realauthfds = [1] MockClassMethod(Server, '_GrabPacket') MockClassMethod(Server, '_HandleAuthPacket') self.server._ProcessInput(fd) self.assertEqual([x[0] for x in self.server.called], ['_GrabPacket', '_HandleAuthPacket']) self.assertEqual(self.server.called[0][1][1], fd)
def testRunIgnoresPacketErrors(self): def RaisePacketError(self, fd): raise PacketError MockClassMethod(Server, '_ProcessInput', RaisePacketError) self.server.authfds = [MockFd()] MockPoll.results = [(0, select.POLLIN)] self.assertRaises(MockFinished, self.server.Run)
def testRunRunsProcessInput(self): MockClassMethod(Server, '_ProcessInput') self.server.authfds = fd = [MockFd()] MockPoll.results = [(0, select.POLLIN)] self.assertRaises(MockFinished, self.server.Run) self.assertEqual(self.server.called, [('_ProcessInput', (fd[0], ), {})])
def testRunInitializes(self): MockClassMethod(Server, '_PrepareSockets') self.assertRaises(MockFinished, self.server.Run) self.assertEqual(self.server.called, [('_PrepareSockets', (), {})]) self.failUnless(isinstance(self.server._fdmap, dict)) self.failUnless(isinstance(self.server._poll, MockPoll))
def testProcessInput(self): MockClassMethod(Proxy, '_GrabPacket') MockClassMethod(Proxy, '_HandleProxyPacket') self.proxy._ProcessInput(self.proxy._proxyfd) self.assertEqual([x[0] for x in self.proxy.called], ['_GrabPacket', '_HandleProxyPacket'])
def testProcessInputNonProxyPort(self): fd = MockFd(fd=111) MockClassMethod(Server, '_ProcessInput') self.proxy._ProcessInput(fd) self.assertEqual(self.proxy.called, [('_ProcessInput', (fd,), {})])