@@ -253,6 +253,30 @@ class TestcaseGenerator(tool.BatchTool):
253253 ]
254254 )
255255
256+ PLACETYPES = [
257+ "Unknown" , # -1 original value
258+ "Country" , # 1
259+ "State" , # 2
260+ "County" , # 3
261+ "City" , # 4
262+ "Parish" , # 5
263+ "Locality" , # 6
264+ "Street" , # 7
265+ "Province" , # 8
266+ "Region" , # 9
267+ "Department" , # 10
268+ "Neighborhood" , # 11
269+ "District" , # 12
270+ "Borough" , # 13
271+ "Municipality" , # 14
272+ "Town" , # 15
273+ "Village" , # 16
274+ "Hamlet" , # 17
275+ "Farm" , # 18
276+ "Building" , # 19
277+ "Number" ,
278+ ] # 20
279+
256280 def __init__ (self , dbstate , user , options_class , name , callback = None ):
257281 uistate = user .uistate
258282 if uistate :
@@ -480,6 +504,33 @@ def run_tool(self, cli=False):
480504 if not cli :
481505 self .top .destroy ()
482506
507+ def generate_persons (self ):
508+ """This creates the persons and families"""
509+ with DbTxn (
510+ _ ("Testcase generator step %d" ) % self .transaction_count , self .db
511+ ) as self .trans , self .progress (
512+ _ ("Generating testcases" ), _ ("Generating families" ), self .max_person_count
513+ ) as self .progress_step :
514+ self .person_count = 0
515+
516+ while True :
517+ if not self .persons_todo :
518+ pers_h = self .generate_person (0 )
519+ self .persons_todo .append (pers_h )
520+ self .parents_todo .append (pers_h )
521+ person_h = self .persons_todo .pop (0 )
522+ self .generate_family (person_h )
523+ if _randint (0 , 3 ) == 0 :
524+ self .generate_family (person_h )
525+ if _randint (0 , 7 ) == 0 :
526+ self .generate_family (person_h )
527+ if self .person_count > self .max_person_count :
528+ break
529+ for child_h in self .parents_todo :
530+ self .generate_parents (child_h )
531+ if self .person_count > self .max_person_count :
532+ break
533+
483534 def generate_data_errors (self , step ):
484535 """This generates errors in the database to test src/plugins/tool/Check
485536 The module names correspond to the checking methods in
@@ -1421,13 +1472,17 @@ def create_all_possible_citations(self, c_h_list, name, message):
14211472
14221473 place = Place ()
14231474 place .set_title (message )
1475+ # Place
14241476 place .add_citation (_choice (c_h_list ))
1425- pname = PlaceName (value = 'All Attribute Test' )
1477+ # Place : Name
1478+ pname = PlaceName (value = "All Attribute Test" )
14261479 pname .add_citation (_choice (c_h_list ))
14271480 place .add_name (pname )
1428- ptype = PlaceType (value = PlaceType .BOROUGH )
1481+ # Place : Type
1482+ ptype = PlaceType ("Borough" )
14291483 ptype .add_citation (_choice (c_h_list ))
14301484 place .add_type (ptype )
1485+ # Place : Attribute
14311486 place .add_attribute (att )
14321487 # Place : MediaRef
14331488 mref = MediaRef ()
@@ -1440,7 +1495,8 @@ def create_all_possible_citations(self, c_h_list, name, message):
14401495 att .add_citation (_choice (c_h_list ))
14411496 mref .add_attribute (att )
14421497 place .add_media_reference (mref )
1443- place .add_attribute (att )
1498+ # Place : EventRef
1499+ place .add_event_ref (eref )
14441500 self .db .add_place (place , self .trans )
14451501
14461502 ref = Repository ()
@@ -1663,6 +1719,7 @@ def generate_family(self, person1_h):
16631719 if person2_h and _randint (0 , 2 ) > 0 :
16641720 self .parents_todo .append (person2_h )
16651721
1722+ self .transaction_count += 1
16661723 fam = Family ()
16671724 self .add_defaults (fam )
16681725 if person1_h :
@@ -1766,6 +1823,7 @@ def generate_parents(self, child_h):
17661823 if _randint (0 , 2 ) > 1 :
17671824 self .parents_todo .append (person2_h )
17681825
1826+ self .transaction_count += 1
17691827 fam = Family ()
17701828 self .add_defaults (fam )
17711829 fam .set_father_handle (person1_h )
@@ -2200,7 +2258,7 @@ def generate_place(self):
22002258 # skip some levels in the place hierarchy
22012259 continue
22022260 place = Place ()
2203- place .set_type (PlaceType ( type_num ) )
2261+ place .set_type (self . PLACETYPES [ type_num ] )
22042262 if parent_handle is not None :
22052263 self .add_parent_place (place , parent_handle )
22062264 if type_num > 1 and _randint (1 , 3 ) == 1 :
@@ -2209,6 +2267,7 @@ def generate_place(self):
22092267 if parent_handle is not None :
22102268 self .add_parent_place (place , parent_handle )
22112269 self .fill_object (place )
2270+ place .group = place .get_type ().get_probable_group ()
22122271 self .db .add_place (place , self .trans )
22132272 parent_handle = place .get_handle ()
22142273 self .generated_places .append (place .get_handle ())
0 commit comments