def convert(self) -> None: """Does the actual conversion.""" try: config = { "input": self.input_value.text(), "output": self.output_value.text(), "rootfamily": self.rootfamily_value.currentData(), "familydepth": str(self.familydepth_value.value()), "imagedir": self.imagedir_value.text(), "nameorder": "little", } if not self.nameorder_value.isChecked(): config["nameorder"] = "big" invoke_dot = False if not self.output_value.text().endswith(".dot"): invoke_dot = True config["output"] = self.output_value.text() + ".dot" self.statusbar.showMessage("Converting to " + config["output"] + "...") ged2dot.convert(config) if invoke_dot: self.statusbar.showMessage("Converting to " + self.output_value.text() + "...") self.to_graphic(config["output"], self.output_value.text()) webbrowser.open("file://" + self.output_value.text()) self.statusbar.showMessage("Conversion finished successfully.") except Exception: # pylint: disable=broad-except self.print_traceback()
def test_no_images(self) -> None: """Tests the happy path.""" config = { "familydepth": "4", "input": "tests/happy.ged", "output": "tests/happy.dot", "rootfamily": "F1", } if os.path.exists(config["output"]): os.unlink(config["output"]) self.assertFalse(os.path.exists(config["output"])) ged2dot.convert(config) self.assertTrue(os.path.exists(config["output"])) with open(config["output"], "r") as stream: self.assertNotIn("images/", stream.read())
def test_bom(self) -> None: """Tests handling of an UTF-8 BOM.""" config = { "familydepth": "4", "input": "tests/bom.ged", "output": "tests/bom.dot", "rootfamily": "F1", "imagedir": "tests/images", } if os.path.exists(config["output"]): os.unlink(config["output"]) self.assertFalse(os.path.exists(config["output"])) # Without the accompanying fix in place, this test would have failed with: # ValueError: invalid literal for int() with base 10: '\ufeff0' ged2dot.convert(config) self.assertTrue(os.path.exists(config["output"]))
def test_image_abspath(self) -> None: """Tests the case when imagedir is an abs path already.""" config = { "familydepth": "4", "input": "tests/happy.ged", "output": "tests/image-abspath.dot", "rootfamily": "F1", "imagedir": os.path.join(os.getcwd(), "tests/images"), } if os.path.exists(config["output"]): os.unlink(config["output"]) self.assertFalse(os.path.exists(config["output"])) ged2dot.convert(config) self.assertTrue(os.path.exists(config["output"])) with open(config["output"], "r") as stream: self.assertIn(config["imagedir"], stream.read())