* src/plugins/TestcaseGenerator.py: Randomize SourceRefs
svn: r5319
This commit is contained in:
parent
916e94bdc3
commit
23828c68ce
@ -1,3 +1,6 @@
|
||||
2005-10-14 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/plugins/TestcaseGenerator.py: Randomize SourceRefs
|
||||
|
||||
2005-10-14 Julio Sanchez <jsanchez@users.sourceforge.net>
|
||||
* src/ChooseParents.py: give unknown sex to the new parent, so that
|
||||
guessing works
|
||||
|
@ -71,6 +71,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
self.persons_todo = []
|
||||
self.parents_todo = []
|
||||
self.person_dates = {}
|
||||
self.generated_sources = []
|
||||
|
||||
self.random_marrtype_list = (RelLib.Family.UNMARRIED, RelLib.Family.CIVIL_UNION,
|
||||
RelLib.Family.UNKNOWN, RelLib.Family.OTHER)
|
||||
@ -78,6 +79,8 @@ class TestcaseGenerator(Tool.Tool):
|
||||
RelLib.Person.CHILD_REL_STEP, RelLib.Person.CHILD_REL_SPONS,
|
||||
RelLib.Person.CHILD_REL_FOST, RelLib.Person.CHILD_REL_UNKWN,
|
||||
RelLib.Person.CHILD_REL_OTHER)
|
||||
self.random_confidence_list = (RelLib.CONF_VERY_LOW, RelLib.CONF_LOW,
|
||||
RelLib.CONF_NORMAL, RelLib.CONF_HIGH, RelLib.CONF_VERY_HIGH)
|
||||
|
||||
# If an active persons exists the generated tree is connected to that person
|
||||
if person:
|
||||
@ -309,35 +312,37 @@ class TestcaseGenerator(Tool.Tool):
|
||||
self.default_url.set_description("GRAMPS Project Homepage")
|
||||
self.default_source = RelLib.Source()
|
||||
self.default_source.set_title("TestcaseGenerator")
|
||||
self.default_source.set_author("GRAMPS")
|
||||
self.default_source.set_publication_info("Randomly generated. No real data.")
|
||||
self.default_source.set_abbreviation("Gramps T.G.")
|
||||
self.default_source.set_note("Generated by TestcaseGenerator")
|
||||
self.default_source.set_data_item("Testcase Attribute", "Value test")
|
||||
self.db.add_source(self.default_source, self.trans)
|
||||
self.default_sourceref = RelLib.SourceRef()
|
||||
self.default_sourceref.set_base_handle(self.default_source.get_handle())
|
||||
self.generated_sources.append( self.default_source.get_handle())
|
||||
self.default_attribute = RelLib.Attribute()
|
||||
self.default_attribute.set_type("Testcase Attribute")
|
||||
self.default_attribute.set_value("Value test")
|
||||
self.default_attribute.set_note("Generated by TestcaseGenerator")
|
||||
self.default_attribute.add_source_reference(self.default_sourceref)
|
||||
self.default_attribute.add_source_reference( self.rand_sourceref())
|
||||
self.default_media = RelLib.MediaObject()
|
||||
self.default_media.set_description("TestcaseGenerator media")
|
||||
self.default_media.set_path("/tmp/TestcaseGenerator.png")
|
||||
self.default_media.set_mime_type("image/png")
|
||||
self.default_media.set_note("Generated by TestcaseGenerator")
|
||||
self.default_media.add_source_reference(self.default_sourceref)
|
||||
self.default_media.add_source_reference( self.rand_sourceref())
|
||||
self.default_media.add_attribute(self.default_attribute)
|
||||
self.db.add_object(self.default_media, self.trans)
|
||||
self.default_mediaref = RelLib.MediaRef()
|
||||
self.default_mediaref.set_reference_handle(self.default_media.get_handle())
|
||||
self.default_mediaref.set_note("Generated by TestcaseGenerator")
|
||||
self.default_mediaref.add_source_reference(self.default_sourceref)
|
||||
self.default_mediaref.add_source_reference( self.rand_sourceref())
|
||||
self.default_mediaref.add_attribute(self.default_attribute)
|
||||
self.default_source.add_media_reference(self.default_mediaref)
|
||||
self.db.commit_source(self.default_source, self.trans)
|
||||
self.default_place = RelLib.Place()
|
||||
self.default_place.set_title("TestcaseGenerator place")
|
||||
self.default_place.set_note("Generated by TestcaseGenerator")
|
||||
self.default_place.add_source_reference(self.default_sourceref)
|
||||
self.default_place.add_source_reference( self.rand_sourceref())
|
||||
self.default_place.add_media_reference(self.default_mediaref)
|
||||
self.default_place.add_url(self.default_url)
|
||||
self.db.add_place(self.default_place, self.trans)
|
||||
@ -349,7 +354,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
self.default_address.set_country("Testcountry")
|
||||
self.default_address.set_postal_code("12345")
|
||||
self.default_address.set_note("Generated by TestcaseGenerator")
|
||||
self.default_address.add_source_reference(self.default_sourceref)
|
||||
self.default_address.add_source_reference( self.rand_sourceref())
|
||||
|
||||
if self.options.handler.options_dict['bugs']:
|
||||
self.generate_broken_relations()
|
||||
@ -761,7 +766,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
firstname = "%s (%d)" % (firstname, alive_in_year)
|
||||
name.set_first_name(firstname)
|
||||
name.set_surname(lastname)
|
||||
name.add_source_reference(self.default_sourceref)
|
||||
name.add_source_reference( self.rand_sourceref())
|
||||
name.set_note("Generated by TestcaseGenerator")
|
||||
np.set_primary_name(name)
|
||||
|
||||
@ -775,7 +780,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
alt_name.set_patronymic( "Testpatronymic")
|
||||
alt_name.set_surname_prefix( "van")
|
||||
alt_name.set_suffix( "the second")
|
||||
alt_name.add_source_reference(self.default_sourceref)
|
||||
alt_name.add_source_reference( self.rand_sourceref())
|
||||
alt_name.set_note("Generated by TestcaseGenerator")
|
||||
np.add_alternate_name( alt_name)
|
||||
|
||||
@ -947,7 +952,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
self.commit_transaction() # COMMIT TRANSACTION STEP
|
||||
|
||||
def add_defaults(self,object,ref_text = ""):
|
||||
object.add_source_reference(self.default_sourceref)
|
||||
object.add_source_reference( self.rand_sourceref())
|
||||
object.add_media_reference(self.default_mediaref)
|
||||
e = RelLib.Event()
|
||||
e.set_privacy( randint(0,5) == 1)
|
||||
@ -955,9 +960,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
e.set_note("Generated by TestcaseGenerator")
|
||||
e.set_cause("Test cause")
|
||||
e.set_description("Test description")
|
||||
sref = RelLib.SourceRef(self.default_sourceref)
|
||||
sref.set_privacy( randint(0,5) == 1)
|
||||
e.add_source_reference(sref)
|
||||
e.add_source_reference( self.rand_sourceref())
|
||||
mref = RelLib.MediaRef(self.default_mediaref)
|
||||
mref.set_privacy( randint(0,5) == 1)
|
||||
e.add_media_reference(mref)
|
||||
@ -1069,9 +1072,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
if randint(0,1) == 1:
|
||||
e.set_description("Test description")
|
||||
if randint(0,1) == 1:
|
||||
sref = self.default_sourceref
|
||||
sref.set_privacy( randint(0,5) == 1)
|
||||
e.add_source_reference( sref)
|
||||
e.add_source_reference( self.rand_sourceref())
|
||||
if randint(0,1) == 1:
|
||||
mref = self.default_mediaref
|
||||
mref.set_privacy( randint(0,5) == 1)
|
||||
@ -1103,9 +1104,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
if randint(0,1) == 1:
|
||||
lds.set_place_handle( self.default_place.get_handle())
|
||||
if randint(0,1) == 1:
|
||||
sref = self.default_sourceref
|
||||
sref.set_privacy( randint(0,5) == 1)
|
||||
lds.add_source_reference( sref)
|
||||
lds.add_source_reference( self.rand_sourceref())
|
||||
if randint(0,1) == 1:
|
||||
lds.set_note("Generated by TestcaseGenerator")
|
||||
if randint(0,1) == 1:
|
||||
@ -1113,6 +1112,22 @@ class TestcaseGenerator(Tool.Tool):
|
||||
lds.set_date_object( d)
|
||||
return lds
|
||||
|
||||
def rand_sourceref( self):
|
||||
sref = RelLib.SourceRef()
|
||||
sref.set_base_handle( choice( self.generated_sources))
|
||||
if randint(0,1) == 1:
|
||||
sref.set_page( "%d, %d" % (randint(2,100), randint(101,500)))
|
||||
if randint(0,1) == 1:
|
||||
sref.set_text("Test 1 test 2 test 3 test 4")
|
||||
if randint(0,1) == 1:
|
||||
sref.set_note("This is a test only.")
|
||||
sref.set_privacy( randint(0,5) == 1)
|
||||
if randint(0,1) == 1:
|
||||
(year, d) = self.rand_date( )
|
||||
sref.set_date_object( d)
|
||||
sref.set_confidence_level( choice( self.random_confidence_list))
|
||||
return sref
|
||||
|
||||
|
||||
def commit_transaction(self):
|
||||
if self.options.handler.options_dict['no_trans']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user