Skip to content

Commit 6563ce9

Browse files
add a test for dependencies.topo_sort()
1 parent d5ab1a0 commit 6563ce9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_dependencies.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ def test_nullable_dependency(thing_tables):
1919
assert len(c) == len(c.fetch()) == 5
2020

2121

22+
def test_topo_sort():
23+
import networkx as nx
24+
import datajoint as dj
25+
26+
graph = nx.DiGraph(
27+
[
28+
("`a`.`a`", "`a`.`m`"),
29+
("`a`.`a`", "`a`.`z`"),
30+
("`a`.`m`", "`a`.`m__part`"),
31+
("`a`.`z`", "`a`.`m__part`"),
32+
]
33+
)
34+
assert dj.dependencies.topo_sort(graph) == [
35+
"`a`.`a`",
36+
"`a`.`z`",
37+
"`a`.`m`",
38+
"`a`.`m__part`",
39+
]
40+
41+
2242
def test_unique_dependency(thing_tables):
2343
"""test nullable unique foreign key"""
2444
# Thing C has a nullable dependency on B whose primary key is composite

0 commit comments

Comments
 (0)