Пример #1
0
 def __to_dot(config: Dict[str, str]) -> io.BytesIO:
     dot = io.BytesIO()
     importer = ged2dot.GedcomImport()
     graph = importer.load(config)
     root_node = ged2dot.graph_find(graph, config["rootfamily"])
     assert root_node
     subgraph = ged2dot.bfs(root_node, config)
     exporter = ged2dot.DotExport()
     exporter.store_to_stream(subgraph, dot, config)
     return dot
Пример #2
0
 def test_level3(self) -> None:
     """Tests that we just ignore a 3rd level (only 0..2 is valid)."""
     config = {
         "familydepth": "0",
         "input": "tests/level3.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.load(config)
     root_family = ged2dot.graph_find(graph, "F1")
     assert root_family
     subgraph = ged2dot.bfs(root_family, config)
     self.assertEqual(len(subgraph), 3)
Пример #3
0
 def test_unexpected_date(self) -> None:
     """Tests that we just ignore a date which is not birth/death."""
     config = {
         "familydepth": "0",
         "input": "tests/unexpected_date.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.load(config)
     root_family = ged2dot.graph_find(graph, "F1")
     assert root_family
     subgraph = ged2dot.bfs(root_family, config)
     self.assertEqual(len(subgraph), 3)
Пример #4
0
 def test_family_depth(self) -> None:
     """Tests handling of the familydepth parameter."""
     config = {
         "familydepth": "0",
         "input": "tests/happy.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.load(config)
     root_family = ged2dot.graph_find(graph, "F1")
     assert root_family
     subgraph = ged2dot.bfs(root_family, config)
     # Just 3 nodes: wife, husband and the family node.
     self.assertEqual(len(subgraph), 3)
Пример #5
0
    def test_no_husband(self) -> None:
        """Tests handling of no husband in a family."""
        config = {
            "familydepth": "0",
            "input": "tests/no_husband.ged",
            "output": "tests/no_husband.dot",
        }
        importer = ged2dot.GedcomImport()
        graph = importer.load(config)
        root_family = ged2dot.graph_find(graph, "F1")
        assert root_family
        neighbours = root_family.get_neighbours()
        # Just 1 node: wife.
        self.assertEqual(len(neighbours), 1)
        self.assertEqual(neighbours[0].get_identifier(), "P1")

        # Test export of a no-husband model.
        subgraph = ged2dot.bfs(root_family, config)
        exporter = ged2dot.DotExport()
        exporter.store(subgraph, config)
Пример #6
0
 def test_cousins_marrying(self) -> None:
     """Tests cousins marrying."""
     config = {
         "familydepth": "4",
         "input": "tests/cousins-marrying.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.load(config)
     root_family = ged2dot.graph_find(graph, "F1")
     assert root_family
     subgraph = ged2dot.bfs(root_family, config)
     # 8 nodes:
     # 1) A
     # 2) B
     # 3) family in which A and B are kids
     # 4) A's family
     # 5) B's family
     # 6) A's kid: C
     # 7) B's kid: D
     # 8) C and D's family
     self.assertEqual(len(subgraph), 8)