Adjusted derivation of edges to preserve definition order.
It was using a set to avoid duplicates, which was randomizing the order of edges, and hence processing. By using a list and testing for existing edges to avoid duplicates, order of definition is preseved.
@@ -20,7 +20,7 @@ from eventsourcing.utils import get_topic
class TestSystem(TestCase):
- def test_graph(self):
+ def test_graph_nodes_and_edges(self):
system = System(
pipes=[
[
@@ -50,6 +50,40 @@ class TestSystem(TestCase):
self.assertEqual(len(system.singles), 1)
+ def test_duplicate_edges_are_eliminated(self):
+ system = System(
+ pipes=[
+ [
+ BankAccounts,
+ EmailProcess,
+ ],
+ [
+ BankAccounts,
+ EmailProcess,
+ ],
+ [Application],
+ ]
+ )
+ self.assertEqual(len(system.nodes), 3)
+ self.assertEqual(system.nodes["BankAccounts"], get_topic(BankAccounts))
+ self.assertEqual(system.nodes["EmailProcess"], get_topic(EmailProcess))
+ self.assertEqual(system.nodes["Application"], get_topic(Application))
+
+ self.assertEqual(system.leaders, ["BankAccounts"])
+ self.assertEqual(system.followers, ["EmailProcess"])
+ self.assertEqual(system.singles, ["Application"])
+
+ self.assertEqual(len(system.edges), 1)
+ self.assertIn(
+ (
+ "BankAccounts",
+ "EmailProcess",
+ ),
+ system.edges,
+ )
+
+ self.assertEqual(len(system.singles), 1)
+
def test_raises_type_error_not_a_follower(self):
with self.assertRaises(TypeError) as cm:
System(
