示例#1
0
	def test_getUndeliverableCount(self):
		i = Incoming()
		self.assertEqual(0, i.getUndeliverableCount())
		i.give([[1, 'string1']])
		self.assertEqual(1, i.getUndeliverableCount())
		i.give([[2, 'string2']])
		self.assertEqual(2, i.getUndeliverableCount())
		i.give([[0, 'string0']])
		self.assertEqual(0, i.getUndeliverableCount())
示例#2
0
	def test_itemsGivenTwice(self):
		"""
		If an already-delivered item is given again, it is completely ignored
		and does not occupy space in the internal cache.
		"""
		i = Incoming()
		i.give([[0, 'string0'], [1, 'string1']])
		self.assertEqual(0, i.getUndeliverableCount())

		i.give([[0, 'string0']])
		self.assertEqual(0, i.getUndeliverableCount())
		i.give([[1, 'string1']])
		self.assertEqual(0, i.getUndeliverableCount())
		i.give([[0, 'string0'], [1, 'string1']])
		self.assertEqual(0, i.getUndeliverableCount())
		i.give([[0, 'string0'], [1, 'string1'], [2, 'string2']])
		self.assertEqual(0, i.getUndeliverableCount())
示例#3
0
	def test_itemLimit(self):
		i = Incoming()
		self.assertEqual(([], False), i.give([[1, 'string1']], itemLimit=3))
		self.assertEqual(([], False), i.give([[2, 'string2']], itemLimit=3))
		self.assertEqual(([], False), i.give([[3, 'string3']], itemLimit=3))
		self.assertEqual(([], True), i.give([[4, 'string4']], itemLimit=3))
		self.assertEqual(([], True), i.give([[5, 'string5']], itemLimit=3))

		# The items we kept giving it past the limit are dropped to the floor
		deliverable, hitLimit = i.give([[0, 'string0']], itemLimit=3)
		self.assertEqual(False, hitLimit)
		self.assertEqual(['string0', 'string1', 'string2', 'string3'], deliverable)

		self.assertEqual(0, i.getUndeliverableCount())
		self.assertEqual(0, i.getMaxConsumption())