Update TestcaseGenerator to work with new transaction code
svn: r16705
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
@@ -46,6 +46,7 @@ import gtk
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.lib
|
import gen.lib
|
||||||
|
from gen.db import DbTxn
|
||||||
from gui.plug import tool
|
from gui.plug import tool
|
||||||
import Utils
|
import Utils
|
||||||
import LdsUtils
|
import LdsUtils
|
||||||
@@ -139,8 +140,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
self.check_persons.set_active( self.options.handler.options_dict['persons'])
|
self.check_persons.set_active( self.options.handler.options_dict['persons'])
|
||||||
self.top.vbox.pack_start(self.check_persons,0,0,5)
|
self.top.vbox.pack_start(self.check_persons,0,0,5)
|
||||||
|
|
||||||
|
# doesn't work any more since revision ... (earlier than version 3.3)
|
||||||
self.check_trans = gtk.CheckButton( _("Don't block transactions"))
|
self.check_trans = gtk.CheckButton( _("Don't block transactions"))
|
||||||
self.check_trans.set_active( self.options.handler.options_dict['no_trans'])
|
#self.check_trans.set_active( self.options.handler.options_dict['no_trans'])
|
||||||
|
self.check_trans.set_active(False)
|
||||||
|
self.check_trans.set_sensitive(False)
|
||||||
self.top.vbox.pack_start(self.check_trans,0,0,5)
|
self.top.vbox.pack_start(self.check_trans,0,0,5)
|
||||||
|
|
||||||
self.check_longnames = gtk.CheckButton( _("Generate long names"))
|
self.check_longnames = gtk.CheckButton( _("Generate long names"))
|
||||||
@@ -219,7 +223,7 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
self.db.disable_signals()
|
self.db.disable_signals()
|
||||||
else:
|
else:
|
||||||
batch = False
|
batch = False
|
||||||
self.trans = self.db.transaction_begin(_("Testcase generator"))
|
with DbTxn(_("Testcase generator"), self.db) as self.trans:
|
||||||
|
|
||||||
if False and self.options.handler.options_dict['no_trans']:
|
if False and self.options.handler.options_dict['no_trans']:
|
||||||
|
|
||||||
@@ -353,7 +357,6 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
if self.person_count > self.options.handler.options_dict['person_count']:
|
if self.person_count > self.options.handler.options_dict['person_count']:
|
||||||
break
|
break
|
||||||
|
|
||||||
self.db.transaction_commit(self.trans,_("Testcase generator"))
|
|
||||||
if not self.options.handler.options_dict['no_trans']:
|
if not self.options.handler.options_dict['no_trans']:
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.request_rebuild()
|
self.db.request_rebuild()
|
||||||
@@ -363,6 +366,9 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
|
|
||||||
def generate_broken_relations(self):
|
def generate_broken_relations(self):
|
||||||
# Create a family, that links to father and mother, but father does not link back
|
# Create a family, that links to father and mother, but father does not link back
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken1","Family links to this person, but person does not link back")
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken1","Family links to this person, but person does not link back")
|
||||||
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken1",None)
|
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken1",None)
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
@@ -376,9 +382,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person2 = self.db.get_person_from_handle(person2_h)
|
person2 = self.db.get_person_from_handle(person2_h)
|
||||||
person2.add_family_handle(fam_h)
|
person2.add_family_handle(fam_h)
|
||||||
self.db.commit_person(person2,self.trans)
|
self.db.commit_person(person2,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Create a family, that misses the link to the father
|
# Create a family, that misses the link to the father
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken2",None)
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken2",None)
|
||||||
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken2",None)
|
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken2",None)
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
@@ -392,9 +400,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person2 = self.db.get_person_from_handle(person2_h)
|
person2 = self.db.get_person_from_handle(person2_h)
|
||||||
person2.add_family_handle(fam_h)
|
person2.add_family_handle(fam_h)
|
||||||
self.db.commit_person(person2,self.trans)
|
self.db.commit_person(person2,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Create a family, that misses the link to the mother
|
# Create a family, that misses the link to the mother
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken3",None)
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken3",None)
|
||||||
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken3",None)
|
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken3",None)
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
@@ -408,9 +418,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person2 = self.db.get_person_from_handle(person2_h)
|
person2 = self.db.get_person_from_handle(person2_h)
|
||||||
person2.add_family_handle(fam_h)
|
person2.add_family_handle(fam_h)
|
||||||
self.db.commit_person(person2,self.trans)
|
self.db.commit_person(person2,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Create a family, that links to father and mother, but father does not link back
|
# Create a family, that links to father and mother, but father does not link back
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken4",None)
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken4",None)
|
||||||
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken4","Family links to this person, but person does not link back")
|
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken4","Family links to this person, but person does not link back")
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
@@ -424,9 +436,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
#person2 = self.db.get_person_from_handle(person2_h)
|
#person2 = self.db.get_person_from_handle(person2_h)
|
||||||
#person2.add_family_handle(fam_h)
|
#person2.add_family_handle(fam_h)
|
||||||
#self.db.commit_person(person2,self.trans)
|
#self.db.commit_person(person2,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Create two married people of same sex.
|
# Create two married people of same sex.
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken5",None)
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken5",None)
|
||||||
person2_h = self.generate_person(gen.lib.Person.MALE,"Broken5",None)
|
person2_h = self.generate_person(gen.lib.Person.MALE,"Broken5",None)
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
@@ -440,9 +454,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person2 = self.db.get_person_from_handle(person2_h)
|
person2 = self.db.get_person_from_handle(person2_h)
|
||||||
person2.add_family_handle(fam_h)
|
person2.add_family_handle(fam_h)
|
||||||
self.db.commit_person(person2,self.trans)
|
self.db.commit_person(person2,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Create a family, that contains an invalid handle to for the father
|
# Create a family, that contains an invalid handle to for the father
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
#person1_h = self.generate_person(gen.lib.Person.MALE,"Broken6",None)
|
#person1_h = self.generate_person(gen.lib.Person.MALE,"Broken6",None)
|
||||||
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken6",None)
|
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken6",None)
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
@@ -456,9 +472,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person2 = self.db.get_person_from_handle(person2_h)
|
person2 = self.db.get_person_from_handle(person2_h)
|
||||||
person2.add_family_handle(fam_h)
|
person2.add_family_handle(fam_h)
|
||||||
self.db.commit_person(person2,self.trans)
|
self.db.commit_person(person2,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Create a family, that contains an invalid handle to for the mother
|
# Create a family, that contains an invalid handle to for the mother
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken7",None)
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken7",None)
|
||||||
#person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken7",None)
|
#person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken7",None)
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
@@ -472,10 +490,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
#person2 = self.db.get_person_from_handle(person2_h)
|
#person2 = self.db.get_person_from_handle(person2_h)
|
||||||
#person2.add_family_handle(fam_h)
|
#person2.add_family_handle(fam_h)
|
||||||
#self.db.commit_person(person2,self.trans)
|
#self.db.commit_person(person2,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
|
|
||||||
# Creates a family where the child does not link back to the family
|
# Creates a family where the child does not link back to the family
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken8",None)
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken8",None)
|
||||||
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken8",None)
|
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken8",None)
|
||||||
child_h = self.generate_person(None,"Broken8",None)
|
child_h = self.generate_person(None,"Broken8",None)
|
||||||
@@ -497,9 +516,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
#child = self.db.get_person_from_handle(child_h)
|
#child = self.db.get_person_from_handle(child_h)
|
||||||
#person2.add_parent_family_handle(fam_h)
|
#person2.add_parent_family_handle(fam_h)
|
||||||
#self.db.commit_person(child,self.trans)
|
#self.db.commit_person(child,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a family where the child is not linked, but the child links to the family
|
# Creates a family where the child is not linked, but the child links to the family
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken9",None)
|
person1_h = self.generate_person(gen.lib.Person.MALE,"Broken9",None)
|
||||||
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken9",None)
|
person2_h = self.generate_person(gen.lib.Person.FEMALE,"Broken9",None)
|
||||||
child_h = self.generate_person(None,"Broken9",None)
|
child_h = self.generate_person(None,"Broken9",None)
|
||||||
@@ -522,36 +543,44 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
child = self.db.get_person_from_handle(child_h)
|
child = self.db.get_person_from_handle(child_h)
|
||||||
child.add_parent_family_handle(fam_h)
|
child.add_parent_family_handle(fam_h)
|
||||||
self.db.commit_person(child,self.trans)
|
self.db.commit_person(child,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person having a non existing birth event handle set
|
# Creates a person having a non existing birth event handle set
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken11",None)
|
person_h = self.generate_person(None,"Broken11",None)
|
||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
event_ref = gen.lib.EventRef()
|
event_ref = gen.lib.EventRef()
|
||||||
event_ref.set_reference_handle("InvalidHandle4")
|
event_ref.set_reference_handle("InvalidHandle4")
|
||||||
person.set_birth_ref(event_ref)
|
person.set_birth_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person having a non existing death event handle set
|
# Creates a person having a non existing death event handle set
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken12",None)
|
person_h = self.generate_person(None,"Broken12",None)
|
||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
event_ref = gen.lib.EventRef()
|
event_ref = gen.lib.EventRef()
|
||||||
event_ref.set_reference_handle("InvalidHandle5")
|
event_ref.set_reference_handle("InvalidHandle5")
|
||||||
person.set_death_ref(event_ref)
|
person.set_death_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person having a non existing event handle set
|
# Creates a person having a non existing event handle set
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken13",None)
|
person_h = self.generate_person(None,"Broken13",None)
|
||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
event_ref = gen.lib.EventRef()
|
event_ref = gen.lib.EventRef()
|
||||||
event_ref.set_reference_handle("InvalidHandle6")
|
event_ref.set_reference_handle("InvalidHandle6")
|
||||||
person.add_event_ref(event_ref)
|
person.add_event_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person with a birth event having an empty type
|
# Creates a person with a birth event having an empty type
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken14",None)
|
person_h = self.generate_person(None,"Broken14",None)
|
||||||
event = gen.lib.Event()
|
event = gen.lib.Event()
|
||||||
event.set_type('')
|
event.set_type('')
|
||||||
@@ -562,9 +591,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
person.set_birth_ref(event_ref)
|
person.set_birth_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person with a death event having an empty type
|
# Creates a person with a death event having an empty type
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken15",None)
|
person_h = self.generate_person(None,"Broken15",None)
|
||||||
event = gen.lib.Event()
|
event = gen.lib.Event()
|
||||||
event.set_description("Test for Broken15")
|
event.set_description("Test for Broken15")
|
||||||
@@ -574,9 +605,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
person.set_death_ref(event_ref)
|
person.set_death_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person with an event having an empty type
|
# Creates a person with an event having an empty type
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken16",None)
|
person_h = self.generate_person(None,"Broken16",None)
|
||||||
event = gen.lib.Event()
|
event = gen.lib.Event()
|
||||||
event.set_description("Test for Broken16")
|
event.set_description("Test for Broken16")
|
||||||
@@ -586,9 +619,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
person.add_event_ref(event_ref)
|
person.add_event_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person with a birth event pointing to nonexisting place
|
# Creates a person with a birth event pointing to nonexisting place
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken17",None)
|
person_h = self.generate_person(None,"Broken17",None)
|
||||||
event = gen.lib.Event()
|
event = gen.lib.Event()
|
||||||
event.set_type(gen.lib.EventType.BIRTH)
|
event.set_type(gen.lib.EventType.BIRTH)
|
||||||
@@ -600,9 +635,11 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
person.set_birth_ref(event_ref)
|
person.set_birth_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
# Creates a person with an event pointing to nonexisting place
|
# Creates a person with an event pointing to nonexisting place
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
person_h = self.generate_person(None,"Broken18",None)
|
person_h = self.generate_person(None,"Broken18",None)
|
||||||
event = gen.lib.Event()
|
event = gen.lib.Event()
|
||||||
event.set_type(gen.lib.EventType.BIRTH)
|
event.set_type(gen.lib.EventType.BIRTH)
|
||||||
@@ -614,7 +651,6 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
person = self.db.get_person_from_handle(person_h)
|
person = self.db.get_person_from_handle(person_h)
|
||||||
person.add_event_ref(event_ref)
|
person.add_event_ref(event_ref)
|
||||||
self.db.commit_person(person,self.trans)
|
self.db.commit_person(person,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
|
|
||||||
def generate_person(self,gender=None,lastname=None, note=None, alive_in_year=None):
|
def generate_person(self,gender=None,lastname=None, note=None, alive_in_year=None):
|
||||||
@@ -624,8 +660,6 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
while gtk.events_pending():
|
while gtk.events_pending():
|
||||||
gtk.main_iteration()
|
gtk.main_iteration()
|
||||||
|
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
np = gen.lib.Person()
|
np = gen.lib.Person()
|
||||||
self.fill_object(np)
|
self.fill_object(np)
|
||||||
|
|
||||||
@@ -641,7 +675,9 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
name = gen.lib.Name()
|
name = gen.lib.Name()
|
||||||
(firstname,lastname) = self.rand_name(lastname, gender)
|
(firstname,lastname) = self.rand_name(lastname, gender)
|
||||||
name.set_first_name(firstname)
|
name.set_first_name(firstname)
|
||||||
name.set_surname(lastname)
|
surname = gen.lib.Surname()
|
||||||
|
surname.set_surname(lastname)
|
||||||
|
name.add_surname(surname)
|
||||||
self.fill_object( name)
|
self.fill_object( name)
|
||||||
np.set_primary_name(name)
|
np.set_primary_name(name)
|
||||||
|
|
||||||
@@ -651,17 +687,24 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
alt_name = gen.lib.Name(name)
|
alt_name = gen.lib.Name(name)
|
||||||
self.fill_object( alt_name)
|
self.fill_object( alt_name)
|
||||||
if randint(0,2) == 1:
|
if randint(0,2) == 1:
|
||||||
alt_name.set_surname(self.rand_text(self.LASTNAME))
|
surname = gen.lib.Surname()
|
||||||
|
surname.set_surname(self.rand_text(self.LASTNAME))
|
||||||
|
alt_name.add_surname(surname)
|
||||||
elif randint(0,2) == 1:
|
elif randint(0,2) == 1:
|
||||||
alt_name.set_surname(lastname)
|
surname = gen.lib.Surname()
|
||||||
|
surname.set_surname(lastname)
|
||||||
|
alt_name.add_surname(surname)
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_first_name( firstname2)
|
alt_name.set_first_name( firstname2)
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_title( self.rand_text(self.SHORT))
|
alt_name.set_title( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_patronymic( self.rand_text(self.FIRSTNAME_MALE))
|
patronymic = gen.lib.Surname()
|
||||||
|
patronymic.set_surname( self.rand_text(self.FIRSTNAME_MALE))
|
||||||
|
patronymic.set_origintype(gen.lib.NameOriginType.PATRONYMIC)
|
||||||
|
alt_name.add_surname(patronymic)
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_surname_prefix( self.rand_text(self.SHORT))
|
alt_name.get_primary_surname().set_prefix( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_suffix( self.rand_text(self.SHORT))
|
alt_name.set_suffix( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
@@ -672,17 +715,24 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
alt_name = gen.lib.Name(name)
|
alt_name = gen.lib.Name(name)
|
||||||
self.fill_object( alt_name)
|
self.fill_object( alt_name)
|
||||||
if randint(0,2) == 1:
|
if randint(0,2) == 1:
|
||||||
alt_name.set_surname(self.rand_text(self.LASTNAME))
|
surname = gen.lib.Surname()
|
||||||
|
surname.set_surname(self.rand_text(self.LASTNAME))
|
||||||
|
alt_name.add_surname(surname)
|
||||||
elif randint(0,2) == 1:
|
elif randint(0,2) == 1:
|
||||||
alt_name.set_surname(lastname)
|
surname = gen.lib.Surname()
|
||||||
|
surname.set_surname(lastname)
|
||||||
|
alt_name.add_surname(surname)
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_first_name( firstname2)
|
alt_name.set_first_name( firstname2)
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_title( self.rand_text(self.SHORT))
|
alt_name.set_title( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_patronymic( self.rand_text(self.FIRSTNAME_MALE))
|
patronymic = gen.lib.Surname()
|
||||||
|
patronymic.set_surname(self.rand_text(self.FIRSTNAME_MALE))
|
||||||
|
patronymic.set_origintype(gen.lib.NameOriginType.PATRONYMIC)
|
||||||
|
alt_name.add_surname(patronymic)
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_surname_prefix( self.rand_text(self.SHORT))
|
alt_name.get_primary_surname().set_prefix( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
alt_name.set_suffix( self.rand_text(self.SHORT))
|
alt_name.set_suffix( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
@@ -754,8 +804,6 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
self.person_count = self.person_count+1
|
self.person_count = self.person_count+1
|
||||||
self.person_dates[person_handle] = (by,dy)
|
self.person_dates[person_handle] = (by,dy)
|
||||||
|
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
return( person_handle)
|
return( person_handle)
|
||||||
|
|
||||||
def generate_family(self,person1_h):
|
def generate_family(self,person1_h):
|
||||||
@@ -790,6 +838,9 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
if person2_h and randint(0,2) > 0:
|
if person2_h and randint(0,2) > 0:
|
||||||
self.parents_todo.append(person2_h)
|
self.parents_todo.append(person2_h)
|
||||||
|
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
self.add_defaults(fam)
|
self.add_defaults(fam)
|
||||||
if person1_h:
|
if person1_h:
|
||||||
@@ -830,7 +881,6 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
self.db.commit_person(child,self.trans)
|
self.db.commit_person(child,self.trans)
|
||||||
if randint(0,3) > 0:
|
if randint(0,3) > 0:
|
||||||
self.persons_todo.append(child_h)
|
self.persons_todo.append(child_h)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
def generate_parents(self,child_h):
|
def generate_parents(self,child_h):
|
||||||
if not child_h:
|
if not child_h:
|
||||||
@@ -856,6 +906,9 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
if randint(0,2) > 1:
|
if randint(0,2) > 1:
|
||||||
self.parents_todo.append(person2_h)
|
self.parents_todo.append(person2_h)
|
||||||
|
|
||||||
|
with DbTxn(_("Testcase generator step %d") % self.transaction_count,
|
||||||
|
self.db) as self.trans:
|
||||||
|
self.transaction_count += 1
|
||||||
fam = gen.lib.Family()
|
fam = gen.lib.Family()
|
||||||
self.add_defaults(fam)
|
self.add_defaults(fam)
|
||||||
fam.set_father_handle(person1_h)
|
fam.set_father_handle(person1_h)
|
||||||
@@ -875,7 +928,6 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
self.db.commit_person(person2,self.trans)
|
self.db.commit_person(person2,self.trans)
|
||||||
child.add_parent_family_handle(fam_h)
|
child.add_parent_family_handle(fam_h)
|
||||||
self.db.commit_person(child,self.trans)
|
self.db.commit_person(child,self.trans)
|
||||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
|
||||||
|
|
||||||
def add_defaults(self, object):
|
def add_defaults(self, object):
|
||||||
self.fill_object( object)
|
self.fill_object( object)
|
||||||
@@ -1050,9 +1102,12 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
o.set_title( self.rand_text(self.SHORT))
|
o.set_title( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
o.set_patronymic( self.rand_text(self.FIRSTNAME_MALE))
|
patronymic = gen.lib.Surname()
|
||||||
|
patronymic.set_surname(self.rand_text(self.FIRSTNAME_MALE))
|
||||||
|
patronymic.set_origintype(gen.lib.NameOriginType.PATRONYMIC)
|
||||||
|
o.add_surname(patronymic)
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
o.set_surname_prefix( self.rand_text(self.SHORT))
|
o.get_primary_surname().set_prefix( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
o.set_suffix( self.rand_text(self.SHORT))
|
o.set_suffix( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
@@ -1101,7 +1156,8 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
o.set_gramps_id( self.rand_text(self.SHORT))
|
o.set_gramps_id( self.rand_text(self.SHORT))
|
||||||
if randint(0,1) == 1:
|
if randint(0,1) == 1:
|
||||||
o.set_marker( self.rand_type(gen.lib.MarkerType()))
|
#o.set_marker( self.rand_type(gen.lib.MarkerType()))
|
||||||
|
pass
|
||||||
|
|
||||||
if issubclass(o.__class__,gen.lib.privacybase.PrivacyBase):
|
if issubclass(o.__class__,gen.lib.privacybase.PrivacyBase):
|
||||||
o.set_privacy( randint(0,5) == 1)
|
o.set_privacy( randint(0,5) == 1)
|
||||||
|
Reference in New Issue
Block a user