summary refs log tree commit diff
path: root/tests/util/test_itertools.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-04-22 18:29:47 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-04-22 18:29:47 +0100
commitc68ed1c5adedb33b998acdcadf2ee89dbebf456d (patch)
treede6ae50742500eb1a95ce694031b229381856a6c /tests/util/test_itertools.py
parentMerge commit '28f255d5f' into anoa/dinsic_release_1_31_0 (diff)
parent1.26.0rc2 (diff)
downloadsynapse-c68ed1c5adedb33b998acdcadf2ee89dbebf456d.tar.xz
Merge commit 'a01605c13' into anoa/dinsic_release_1_31_0
Diffstat (limited to 'tests/util/test_itertools.py')
-rw-r--r--tests/util/test_itertools.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/util/test_itertools.py b/tests/util/test_itertools.py

index 522c8061f9..1ef0af8e8f 100644 --- a/tests/util/test_itertools.py +++ b/tests/util/test_itertools.py
@@ -92,3 +92,15 @@ class SortTopologically(TestCase): # Valid orderings are `[1, 3, 2, 4]` or `[1, 2, 3, 4]`, but we should # always get the same one. self.assertEqual(list(sorted_topologically([4, 3, 2, 1], graph)), [1, 2, 3, 4]) + + def test_duplicates(self): + "Test that a graph with duplicate edges work" + graph = {1: [], 2: [1, 1], 3: [2, 2], 4: [3]} # type: Dict[int, List[int]] + + self.assertEqual(list(sorted_topologically([4, 3, 2, 1], graph)), [1, 2, 3, 4]) + + def test_multiple_paths(self): + "Test that a graph with multiple paths between two nodes work" + graph = {1: [], 2: [1], 3: [2], 4: [3, 2, 1]} # type: Dict[int, List[int]] + + self.assertEqual(list(sorted_topologically([4, 3, 2, 1], graph)), [1, 2, 3, 4])