예제 #1
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #6
0
 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)
예제 #7
0
 def testBindClosesSocket(self):
     s = MockSocket(socket.AF_INET, socket.SOCK_DGRAM)
     self.client._socket = s
     self.client.bind((BIND_IP, BIND_PORT))
     self.assertEqual(s.closed, True)