Beispiel #1
0
	def test_appendExtendQueueStart3(self):
		q = Queue()
		q.append('zero')
		q.extend(['one', 'two'])
		self.assertEqual([], list(q.iterItems(start=3)))
		# iterItems is idempotent
		self.assertEqual([], list(q.iterItems(start=3)))
Beispiel #2
0
	def test_appendExtendQueue(self):
		q = Queue()
		q.append('zero')
		q.extend(['one', 'two'])
		self.assertEqual([(0, 'zero'), (1, 'one'), (2, 'two')], list(q.iterItems(start=0)))
		# iterItems is idempotent
		self.assertEqual([(0, 'zero'), (1, 'one'), (2, 'two')], list(q.iterItems(start=0)))
Beispiel #3
0
	def test_handleSACKOnlyAckNumber(self):
		q = Queue()
		q.append('zero')
		q.extend(['one', 'two'])

		self.assertEqual(False, q.handleSACK(SACK(0, ())))
		self.assertEqual([(1, 'one'), (2, 'two')], list(q.iterItems(start=1)))

		# Removing again is idempotent
		self.assertEqual(False, q.handleSACK(SACK(0, ())))
		self.assertEqual([(1, 'one'), (2, 'two')], list(q.iterItems(start=1)))
Beispiel #4
0
	def test_iterItemsNoStartNumber(self):
		"""
		A L{start} for iterItems is not required.
		"""
		q = Queue()
		q.append('zero')
		q.extend(['one', 'two'])
		self.assertEqual([(0, 'zero'), (1, 'one'), (2, 'two')], list(q.iterItems()))
		self.assertEqual(False, q.handleSACK(SACK(-1, ())))
		self.assertEqual([(0, 'zero'), (1, 'one'), (2, 'two')], list(q.iterItems()))
		self.assertEqual(False, q.handleSACK(SACK(0, ())))
		self.assertEqual([(1, 'one'), (2, 'two')], list(q.iterItems()))
Beispiel #5
0
	def test_ackNumberTooHigh1(self):
		q = Queue()
		q.append('zero')
		badSACK = q.handleSACK(SACK(1, ()))
		self.assertEqual(True, badSACK)
		# Items were still removed, despite it being a bad SACK
		self.assertEqual([], list(q.iterItems()))
Beispiel #6
0
	def test_sackNumberTooHigh(self):
		q = Queue()
		q.extend(['zero', 'one', 'two', 'three'])
		badSACK = q.handleSACK(SACK(0, (2, 5)))
		self.assertEqual(True, badSACK)
		# Items were still removed, despite it being a bad SACK
		self.assertEqual([(1, 'one'), (3, 'three')], list(q.iterItems()))
Beispiel #7
0
	def test_handleSACKBothAckAndSackNumRemoveItems(self):
		"""
		Another handleSACK test.  This covers a wrong-variable-in-loop bug
		we had.
		"""
		q = Queue()
		q.extend(['zero', 'one', 'two', 'three', 'four'])
		self.assertEqual(False, q.handleSACK(SACK(0, (1, 3))))
		self.assertEqual([(2, 'two'), (4, 'four')], list(q.iterItems()))
Beispiel #8
0
	def test_handleSACK(self):
		"""
		handleSACK actually removes the selectively-acknowledged items from the queue 
		"""
		q = Queue()
		q.append('zero')
		q.extend(['one', 'two', 'three'])
		self.assertEqual([(0, 'zero'), (1, 'one'), (2, 'two'), (3, 'three')], list(q.iterItems()))
		self.assertEqual(False, q.handleSACK(SACK(-1, (1,))))
		self.assertEqual([(0, 'zero'), (2, 'two'), (3, 'three')], list(q.iterItems()))
		self.assertEqual(False, q.handleSACK(SACK(0, (3,))))
		self.assertEqual([(2, 'two')], list(q.iterItems()))
		q.append('four')
		self.assertEqual([(2, 'two'), (4, 'four')], list(q.iterItems()))
		# although this is a very strange SACK because it should have
		# been (4, ()), it is still legal
		self.assertEqual(False, q.handleSACK(SACK(0, (2, 4))))
		self.assertEqual([], list(q.iterItems()))
		q.append('five')
		self.assertEqual([(5, 'five')], list(q.iterItems()))
Beispiel #9
0
	def test_iterEmptyQueue(self):
		q = Queue()
		self.assertEqual([], list(q.iterItems(start=0)))
Beispiel #10
0
	def test_handleSACKToHigherNum(self):
		q = Queue()
		q.extend(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'])
		self.assertEqual(False, q.handleSACK(SACK(1, ())))
		self.assertEqual(False, q.handleSACK(SACK(3, ())))

		# There should be 5 items left in the queue
		self.assertEqual([(4,'4'), (5,'5'), (6,'6'), (7,'7'), (8,'8'), (9,'9'), (10,'10')], list(q.iterItems(start=4)))