|
@@ -42,3 +42,49 @@ def test_digraph_single_family():
|
|
|
"relation-father-mother" -> child
|
|
|
}"""
|
|
|
assert graph.source == expected_graph
|
|
|
+
|
|
|
+
|
|
|
+def test_digraph_grandparents():
|
|
|
+ collection = PersonCollection()
|
|
|
+ father = Person("father")
|
|
|
+ father.father = Person("grandfather")
|
|
|
+ father.mother = Person("grandmother")
|
|
|
+ child_a = Person("child-a")
|
|
|
+ child_a.father = father
|
|
|
+ child_a.mother = Person("mother")
|
|
|
+ collection.add_person(child_a)
|
|
|
+ child_b = Person("child-b")
|
|
|
+ child_b.father = father
|
|
|
+ child_b.mother = Person("mother")
|
|
|
+ collection.add_person(child_b)
|
|
|
+ graph = digraph(collection)
|
|
|
+ expected_graph = """digraph yamily {
|
|
|
+ subgraph cluster_mother {
|
|
|
+ rank=same style=invisible
|
|
|
+ mother [label=mother shape=box]
|
|
|
+ "relation-father-mother" [shape=point width=0]
|
|
|
+ father -> "relation-father-mother" [arrowhead=none constraint=False]
|
|
|
+ mother -> "relation-father-mother" [arrowhead=none constraint=False]
|
|
|
+ father [label=father shape=box]
|
|
|
+ }
|
|
|
+ subgraph cluster_grandmother {
|
|
|
+ rank=same style=invisible
|
|
|
+ grandmother [label=grandmother shape=box]
|
|
|
+ "relation-grandfather-grandmother" [shape=point width=0]
|
|
|
+ grandfather -> "relation-grandfather-grandmother" [arrowhead=none constraint=False]
|
|
|
+ grandmother -> "relation-grandfather-grandmother" [arrowhead=none constraint=False]
|
|
|
+ grandfather [label=grandfather shape=box]
|
|
|
+ }
|
|
|
+ subgraph "cluster_child-a" {
|
|
|
+ rank=same style=invisible
|
|
|
+ "child-a" [label="child-a" shape=box]
|
|
|
+ }
|
|
|
+ subgraph "cluster_child-b" {
|
|
|
+ rank=same style=invisible
|
|
|
+ "child-b" [label="child-b" shape=box]
|
|
|
+ }
|
|
|
+ "relation-grandfather-grandmother" -> father
|
|
|
+ "relation-father-mother" -> "child-a"
|
|
|
+ "relation-father-mother" -> "child-b"
|
|
|
+}"""
|
|
|
+ assert graph.source == expected_graph
|