class ReportControl: def tearDown(self): out, err = self.call("-y", "--remove", TREE_NAME) out, err = self.call("-y", "--remove", TREE_NAME + "_import_gedcom") def call(self, *args): print("call:", args) self.gramps = Gramps() out, err = self.gramps.run(*args) print("out:", out, "err:", err) return out, err def __init__(self): super().__init__() self.tearDown() # removes it if it existed out, err = self.call("-C", TREE_NAME, "--import", example) db = open_database(TREE_NAME, force_unlock=True) db.Person.filter(lambda person: person.gramps_id == "I0000").tag( "Cool") db.close() def addreport(self, class_, report_name, test_function, files, **options): test_name = report_name.replace("-", "_") setattr( class_, test_name, dynamic_report_method(report_name, test_function, files, "--force", "-O", TREE_NAME, "--action", "report", "--options", "name=%s" % report_name, **options)) def addcli(self, class_, report_name, test_function, files, *args, **options): test_name = report_name.replace("-", "_") setattr(class_, test_name, dynamic_cli_method(report_name, test_function, files, *args))
def call(*args): """ Call Gramps to perform the action with out and err captured """ print("call:", args) gramps = Gramps(user=User()) out, err = gramps.run(*args) print("out:", out, "err:", err) return out, err
def call(*args): """ Call Gramps to perform the action with out and err captured """ #print("call:", args) gramps = Gramps(user=User()) out, err = gramps.run(*args) #print("out:", out, "err:", err) return out, err
def call(*args): """ Call Gramps to perform the action with out and err captured """ print("call:", args) gramps = Gramps(user=User(auto_accept=True, quiet=True)) out, err = gramps.run(*args) print("out:", out, "err:", err) return out, err
class ReportControl: def tearDown(self): out, err = self.call("-y", "--remove", TREE_NAME) # out, err = self.call("-y", "--remove", TREE_NAME + "_import_gedcom") def call(self, *args): #print("call:", args) self.gramps = Gramps(user=User()) out, err = self.gramps.run(*args) #print("out:", out, "err:", err) return out, err def __init__(self): super().__init__() self.tearDown() # removes it if it existed out, err = self.call("-C", TREE_NAME, "--import", example) def addreport(self, class_, report_name, test_function, files, **options): test_name = "test_" + report_name.replace("-", "_") setattr( class_, test_name, dynamic_report_method(report_name, test_function, files, "--force", "-O", TREE_NAME, "--action", "report", "--options", "name=%s" % report_name, **options)) def addcli(self, class_, report_name, test_function, files, *args, **options): test_name = "test_" + report_name.replace("-", "_") setattr( class_, test_name, dynamic_cli_method(report_name, test_function, files, *args, **options))
def call(*args): """ Call Gramps to perform the action with out and err captured """ if __debug__: print("call: %s", args) gramps = Gramps(user=User(auto_accept=True, quiet=True)) # gramps = Gramps(user=User(auto_accept=True)) out, err = gramps.run(*args) # print("out:", out, "err:", err) return out, err
class CLITest(unittest.TestCase): def tearDown(self): if os.path.exists(example_copy): os.remove(example_copy) self.call("--remove", "Test: test1_cli") def setUp(self): self.gramps = Gramps() self.tearDown() def call(self, *args, stdin=None): self.gramps.run(*args, stdin=stdin) def test1a_cli(self): self.call("-C", "Test: test1_cli", "--import", example) def test1b_cli(self): self.call("-O", "Test: test1_cli", "--export", example_copy)
class BSDDB(object): NAME = "Example BSDDB Test" backend = "bsddb" def __init__(self): self.gramps = Gramps() self.call("--config=behavior.database-backend:" + self.backend, "-C", self.NAME, "--import", example) self.db = open_database(self.NAME, force_unlock=True) def call(self, *args, stdin=None): return self.gramps.run(*args, stdin=stdin) def close(self): self.db.close() self.call("-r", self.NAME)
class BSDDB: NAME = "Example BSDDB Test" backend = "bsddb" def __init__(self): self.gramps = Gramps() self.call("--config=database.backend:" + self.backend, "-C", self.NAME, "--import", example) self.db = open_database(self.NAME, force_unlock=True) def call(self, *args, stdin=None): return self.gramps.run(*args, stdin=stdin) def close(self): self.db.close() self.call("-r", self.NAME)
class ReportControl(object): def tearDown(self): out, err = self.call("-y", "--remove", TREE_NAME) def call(self, *args): print("call:", args) self.gramps = Gramps() out, err = self.gramps.run(*args) print("out:", out, "err:", err) return out, err def __init__(self): super().__init__() self.tearDown() # removes it if it existed out, err = self.call("-C", TREE_NAME, "--import", example) out, err = self.call("-O", TREE_NAME, "--action", "report", "--options", "show=all") self.reports = [] for line in err.split("\n"): if line.startswith(" "): report_name, description = line.split("- ", 1) self.reports.append(report_name.strip()) def testall(self, class_): count = 0 print(self.reports) for report_name in self.reports: print("add attr:", report_name) setattr(class_, "test_%s" % count, dynamic_method( "--force", "-O", TREE_NAME, "--action", "report", "--options", "name=%s" % report_name)) count += 1 def addtest(self, class_, report_name, test_function, options): test_name = report_name.replace("-", "_") setattr(class_, test_name, dynamic_method( report_name, test_function, "--force", "-O", TREE_NAME, "--action", "report", "--options", "name=%s,%s" % (report_name, options)))
class ReportControl: def tearDown(self): out, err = self.call("-y", "--remove", TREE_NAME) out, err = self.call("-y", "--remove", TREE_NAME + "_import_gedcom") def call(self, *args): print("call:", args) self.gramps = Gramps() out, err = self.gramps.run(*args) print("out:", out, "err:", err) return out, err def __init__(self): super().__init__() self.tearDown() # removes it if it existed out, err = self.call("-C", TREE_NAME, "--import", example) db = open_database(TREE_NAME, force_unlock=True) db.Person.filter(lambda person: person.gramps_id == "I0000").tag("Cool") db.close() def addreport(self, class_, report_name, test_function, files, **options): test_name = report_name.replace("-", "_") setattr(class_, test_name, dynamic_report_method( report_name, test_function, files, "--force", "-O", TREE_NAME, "--action", "report", "--options", "name=%s" % report_name, **options)) def addcli(self, class_, report_name, test_function, files, *args, **options): test_name = report_name.replace("-", "_") setattr(class_, test_name, dynamic_cli_method( report_name, test_function, files, *args))
def call(cls, *args): print("call:", args) gramps = Gramps() out, err = gramps.run(*args) print("out:", out, "err:", err) return out, err
def call(cls, *args): #print("call:", args) gramps = Gramps(user=User()) out, err = gramps.run(*args) #print("out:", out, "err:", err) return out, err