def testSingleRetry(self): self.client.retries = 1 self.client.timeout = 0 packet = MockPacket(AccessRequest) self.assertRaises(Timeout, self.client._SendPacket, packet, 432) self.assertEqual(self.client._socket.output, [("request packet", (self.server, 432))])
def testValidReply(self): self.client.retries = 1 self.client.timeout = 1 self.client._socket = MockSocket(1, 2, six.b("valid reply")) packet = MockPacket(AccountingRequest, verify=True) reply = self.client._SendPacket(packet, 432) self.failUnless(reply is packet.reply)
def testInvalidReply(self): self.client.retries = 1 self.client.timeout = 1 self.client._socket = MockSocket(1, 2, six.b("invalid reply")) MockPoll.results = [(1, select.POLLIN)] packet = MockPacket(AccountingRequest, verify=False) self.assertRaises(Timeout, self.client._SendPacket, packet, 432)
def testIgnorePacketError(self): self.client.retries = 1 self.client.timeout = 1 self.client._socket = MockSocket(1, 2, six.b("valid reply")) self.client._poll = MockPoll() MockPoll.results = [(1, select.POLLIN)] packet = MockPacket(AccountingRequest, verify=True, error=True) self.assertRaises(Timeout, self.client._SendPacket, packet, 432)
def testInvalidReply(self): # TODO: work out how to make test work for BSD if not hasattr(select, 'POLLIN'): return self.client.retries = 1 self.client.timeout = 1 self.client._socket = MockSocket(1, 2, six.b("invalid reply")) MockPoll.results = [(1, select.POLLIN)] packet = MockPacket(AccountingRequest, verify=False) self.assertRaises(Timeout, self.client._SendPacket, packet, 432)
def testValidReply(self): self.client.retries = 1 self.client.timeout = 1 self.client._socket = MockSocket(1, 2, six.b("valid reply")) self.client._poll = MockPoll() MockPoll.results = [(1, select.POLLIN)] packet = MockPacket(AccountingRequest, verify=True) reply = self.client._SendPacket(packet, 432) self.failUnless(reply is packet.reply)
def testValidReply(self): # TODO: work out how to make test work for BSD if not hasattr(select, 'POLLIN'): return self.client.retries = 1 self.client.timeout = 1 self.client._socket = MockSocket(1, 2, six.b("valid reply")) self.client._poll = MockPoll() MockPoll.results = [(1, select.POLLIN)] packet = MockPacket(AccountingRequest, verify=True) reply = self.client._SendPacket(packet, 432) self.failUnless(reply is packet.reply)
def testDoubleAccountDelay(self): self.client.retries = 3 self.client.timeout = 1 packet = MockPacket(AccountingRequest) self.assertRaises(Timeout, self.client._SendPacket, packet, 432) self.assertEqual(packet["Acct-Delay-Time"], [2])
def testAuthDelay(self): self.client.retries = 2 self.client.timeout = 1 packet = MockPacket(AccessRequest) self.assertRaises(Timeout, self.client._SendPacket, packet, 432) self.failIf("Acct-Delay-Time" in packet)