def test_tranmission_queue_count(self):
     # Test property count of TransmissionQueue
     tQ = TransmissionQueue()
     now = time.time()
     node = self._create_node()
     msg = self._create_msg()
     # 0 messages in queue
     self.assertEquals(tQ.Count, 0)
     tQ.enqueue_message(msg, now)
     # 1 message in queue
     self.assertEquals(tQ.Count, 1)
     msg2 = self._create_msg()
     tQ.enqueue_message(msg2, now)
     # 2 messages in queue
     self.assertEquals(tQ.Count, 2)
     tQ.dequeue_message(msg)
     # Dequeue message from queue, leaving 1 message
     self.assertEquals(tQ.Count, 1)
示例#2
0
 def test_tranmission_queue_count(self):
     # Test property count of TransmissionQueue
     tQ = TransmissionQueue()
     now = time.time()
     node = self._create_node()
     msg = self._create_msg()
     # 0 messages in queue
     self.assertEqual(tQ.Count, 0)
     tQ.enqueue_message(msg, now)
     # 1 message in queue
     self.assertEqual(tQ.Count, 1)
     msg2 = self._create_msg()
     tQ.enqueue_message(msg2, now)
     # 2 messages in queue
     self.assertEqual(tQ.Count, 2)
     tQ.dequeue_message(msg)
     # Dequeue message from queue, leaving 1 message
     self.assertEqual(tQ.Count, 1)
 def test_tranmission_queue_dequeue_message(self):
     # Test that a message can be dequeued correctly
     tQ = TransmissionQueue()
     now = time.time()
     node = self._create_node()
     msg = self._create_msg()
     # Add a message to the queue
     tQ.enqueue_message(msg, now)
     self.assertIn(msg.Identifier, tQ._messages)
     self.assertIn(msg.Identifier, tQ._times)
     self.assertIn((now, msg.Identifier), tQ._heap)
     # Dequeue message we just added
     tQ.dequeue_message(msg)
     self.assertNotIn(msg.Identifier, tQ._messages)
     self.assertNotIn(msg.Identifier, tQ._times)
     self.assertNotIn((now, msg.Identifier), tQ._heap)
     # Test that if we try to dequeue a message that is not in the queue
     # That is does not break the test
     tQ.dequeue_message(msg)
     self.assertNotIn(msg.Identifier, tQ._messages)
     self.assertNotIn(msg.Identifier, tQ._times)
     self.assertNotIn((now, msg.Identifier), tQ._heap)
示例#4
0
 def test_tranmission_queue_dequeue_message(self):
     # Test that a message can be dequeued correctly
     tQ = TransmissionQueue()
     now = time.time()
     node = self._create_node()
     msg = self._create_msg()
     # Add a message to the queue
     tQ.enqueue_message(msg, now)
     self.assertIn(msg.Identifier, tQ._messages)
     self.assertIn(msg.Identifier, tQ._times)
     self.assertIn((now, msg.Identifier), tQ._heap)
     # Dequeue message we just added
     tQ.dequeue_message(msg)
     self.assertNotIn(msg.Identifier, tQ._messages)
     self.assertNotIn(msg.Identifier, tQ._times)
     self.assertNotIn((now, msg.Identifier), tQ._heap)
     # Test that if we try to dequeue a message that is not in the queue
     # That is does not break the test
     tQ.dequeue_message(msg)
     self.assertNotIn(msg.Identifier, tQ._messages)
     self.assertNotIn(msg.Identifier, tQ._times)
     self.assertNotIn((now, msg.Identifier), tQ._heap)