8from unittest
import TestCase, main
20class TestCalculationQueue(TestCase):
23 self.calculation_queue = CalculationQueue()
24 self.calculation_queue.queue = MockQueue()
29 self.calculation_queue.put(
"TestItem",
"TestContent")
30 self.calculation_queue.put(
"TestItem2", 2.34)
31 self.calculation_queue.put(
"TestItem3", a)
33 items = self.calculation_queue.queue.internal_storage
35 self.assertEqual(len(items), 3)
36 self.assertEqual(items[0], CalculationQueueItem(
"TestItem",
"TestContent"))
37 self.assertEqual(items[1], CalculationQueueItem(
"TestItem2", 2.34))
38 self.assertEqual(items[2], CalculationQueueItem(
"TestItem3", a))
40 def test_fill_results_no_dubs(self):
43 self.calculation_queue.put(
"TestItem",
"TestContent")
44 self.calculation_queue.put(
"TestItem2", 2.34)
45 self.calculation_queue.put(
"TestItem3", a)
47 self.calculation_queue.fill_results()
49 self.assertEqual(self.calculation_queue.get(
"TestItem"),
"TestContent")
50 self.assertEqual(self.calculation_queue.get(
"TestItem2"), 2.34)
51 self.assertEqual(self.calculation_queue.get(
"TestItem3"), a)
53 self.assertIn(
"TestItem", self.calculation_queue.get_keys())
54 self.assertIn(
"TestItem2", self.calculation_queue.get_keys())
55 self.assertIn(
"TestItem3", self.calculation_queue.get_keys())
57 def test_fill_results_dubs(self):
58 self.calculation_queue.put(
"TestItem",
"TestContent")
59 self.calculation_queue.put(
"TestItem", 2.34)
60 self.calculation_queue.put(
"TestItem2",
"OtherContent")
62 self.calculation_queue.fill_results()
64 self.assertEqual(self.calculation_queue.get(
"TestItem"), 2.34)
65 self.assertEqual(self.calculation_queue.get(
"TestItem2"),
"OtherContent")
67 self.assertIn(
"TestItem", self.calculation_queue.get_keys())
68 self.assertIn(
"TestItem2", self.calculation_queue.get_keys())
71if __name__ ==
"__main__":