|
@@ -0,0 +1,44 @@
|
|
|
+# yamify - define family trees in YAML
|
|
|
+#
|
|
|
+# Copyright (C) 2020 Fabian Peter Hammerle <fabian@hammerle.me>
|
|
|
+#
|
|
|
+# This program is free software: you can redistribute it and/or modify
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
|
+# (at your option) any later version.
|
|
|
+#
|
|
|
+# This program is distributed in the hope that it will be useful,
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+# GNU General Public License for more details.
|
|
|
+#
|
|
|
+# You should have received a copy of the GNU General Public License
|
|
|
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
+
|
|
|
+from yamily import Person, PersonCollection
|
|
|
+from yamily._graphviz import digraph
|
|
|
+
|
|
|
+
|
|
|
+def test_digraph_single_family():
|
|
|
+ collection = PersonCollection()
|
|
|
+ child = Person("child")
|
|
|
+ child.father = Person("father")
|
|
|
+ child.mother = Person("mother")
|
|
|
+ collection.add_person(child)
|
|
|
+ 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_child {
|
|
|
+ rank=same style=invisible
|
|
|
+ child [label=child shape=box]
|
|
|
+ }
|
|
|
+ "relation-father-mother" -> child
|
|
|
+}"""
|
|
|
+ assert graph.source == expected_graph
|