示例#1
0
 def test_str(self) -> None:
     """Tests __str()__."""
     config = {
         "input": "tests/hello.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.tokenize(config)
     family = ged2dot.graph_find(graph, "F1")
     # Make sure that this doesn't loop.
     self.assertNotEqual(str(family), "")
示例#2
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
示例#3
0
 def test_big_endian_name(self) -> None:
     """Tests the case when the name starts with the family name."""
     config = {
         "input": "tests/hello.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.tokenize(config)
     individual = ged2dot.graph_find(graph, "P1")
     assert individual
     assert isinstance(individual, ged2dot.Individual)
     self.assertIn("A<br/>Alice", individual.get_label(image_dir="", name_order="big"))
示例#4
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)
示例#5
0
 def test_multiline_note(self) -> None:
     """Tests multiline notes."""
     config = {
         "familydepth": "4",
         "input": "tests/multiline-note.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.load(config)
     person = ged2dot.graph_find(graph, "P2")
     assert person
     assert isinstance(person, ged2dot.Individual)
     self.assertEqual(person.get_config().get_note(), "This is a note with\n3\nlines")
示例#6
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)
示例#7
0
 def test_no_surname(self) -> None:
     """Tests the no surname case."""
     config = {
         "familydepth": "4",
         "input": "tests/no_surname.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.tokenize(config)
     individual = ged2dot.graph_find(graph, "P1")
     assert individual
     assert isinstance(individual, ged2dot.Individual)
     self.assertEqual(individual.get_surname(), "")
     self.assertEqual(individual.get_forename(), "Alice")
示例#8
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)
示例#9
0
 def test_nosex(self) -> None:
     """Tests the no sex case."""
     config = {
         "familydepth": "4",
         "input": "tests/nosex.ged",
     }
     importer = ged2dot.GedcomImport()
     graph = importer.tokenize(config)
     individual = ged2dot.graph_find(graph, "P3")
     assert individual
     assert isinstance(individual, ged2dot.Individual)
     self.assertIn("placeholder-u", individual.get_label("tests/images", "little"))
     self.assertEqual(individual.get_color(), "black")
示例#10
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)
示例#11
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)