summary refs log tree commit diff
path: root/tests/util
diff options
context:
space:
mode:
authorJason Robinson <jasonr@matrix.org>2021-01-25 15:55:54 +0200
committerJason Robinson <jasonr@matrix.org>2021-01-25 15:55:54 +0200
commitfe18882bb5759133b8921b74d29d4a1906a69655 (patch)
treebfb3ff30c09f50e0e8458eaff698d8509bf23496 /tests/util
parentMerge branch 'develop' into jaywink/admin-forward-extremities (diff)
parentMerge tag 'v1.26.0rc2' into develop (diff)
downloadsynapse-fe18882bb5759133b8921b74d29d4a1906a69655.tar.xz
Merge remote-tracking branch 'origin/develop' into jaywink/admin-forward-extremities
Diffstat (limited to 'tests/util')
-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])