Fix event chain bg update. (#9118)

We passed in a graph to `sorted_topologically` which didn't have an
entry for each node (as we dropped nodes with no edges).
This commit is contained in:
Erik Johnston 2021-01-14 18:57:32 +00:00 committed by GitHub
parent d2479c6870
commit 1a08e0cdab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -56,6 +56,14 @@ class SortTopologically(TestCase):
graph = {} # type: Dict[int, List[int]]
self.assertEqual(list(sorted_topologically([], graph)), [])
def test_handle_empty_graph(self):
"Test that a graph where a node doesn't have an entry is treated as empty"
graph = {} # type: Dict[int, List[int]]
# For disconnected nodes the output is simply sorted.
self.assertEqual(list(sorted_topologically([1, 2], graph)), [1, 2])
def test_disconnected(self):
"Test that a graph with no edges work"