Repository: LibertyAces/BitSwanPump

Issue:
IteratorSource fails with TypeError
`Pipeline 'Pipeline' stopped due to a processing error: 'list_iterator' object is not callable (<class 'TypeError'>)`

Discussion:

Patch:
diff --git a/bspump/common/iterator.py b/bspump/common/iterator.py
index 66353c44..575ab6d4 100644
--- a/bspump/common/iterator.py
+++ b/bspump/common/iterator.py
@@ -15,7 +15,7 @@ class IteratorSource(TriggerSource):
 
 
 	async def cycle(self, *args, **kwags):
-		for event in self.Iterator():
+		for event in self.Iterator:
 			await self.process(event)
 
 


Test patch:
diff --git a/test/common/test_iterator.py b/test/common/test_iterator.py
index 15f8f12a..613bc819 100644
--- a/test/common/test_iterator.py
+++ b/test/common/test_iterator.py
@@ -1,10 +1,11 @@
+from bspump.unittest import UnitTestSink
+from bspump.common import IteratorSource
+from bspump import Pipeline
+
 import bspump.unittest
 import bspump.common
 
 
-# TODO TestIteratorSource
-
-
 class TestIteratorGenerator(bspump.unittest.ProcessorTestCase):
 
 	def test_iterator_generator(self):
@@ -23,3 +24,30 @@ class TestIteratorGenerator(bspump.unittest.ProcessorTestCase):
 			[event for context, event in output],
 			[i for i in event_message]
 		)
+
+
+class TestIteratorSource(bspump.unittest.ProcessorTestCase):
+
+	def test_iterator_source(self):
+		svc = self.App.get_service("bspump.PumpService")
+
+		iterator = iter([1, 2, 3])
+
+		pipeline = Pipeline(app=self.App)
+		sink = UnitTestSink(self.App, pipeline)
+		source = IteratorSource(self.App, pipeline, iterator)
+		pipeline.build(
+			source,
+			sink
+		)
+
+		pipeline.PubSub.subscribe("bspump.pipeline.cycle_end!", self._on_finished)
+
+		svc.add_pipeline(pipeline)
+		source.TriggerEvent.set()
+		self.App.run()
+
+		self.assertEqual([({}, 1), ({}, 2), ({}, 3)], sink.Output)
+
+	def _on_finished(self, event_name, pipeline):
+		self.App.stop()