From 83bb583b3ec180a89e7ee768be664a56be61d251 Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Thu, 22 Feb 2007 20:56:58 +0000 Subject: [PATCH] * plugins/TestcaseGenerator.py: Generate new Note objects svn: r8211 --- ChangeLog | 3 +++ src/plugins/TestcaseGenerator.py | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7217950df..824b0201e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2007-02-22 Martin Hawlisch + * plugins/TestcaseGenerator.py: Generate new Note objects + 2007-02-22 Alex Roitman * src/GrampsDb/_GrampsBSDDB.py (reindex_reference_map): Typo. * src/GrampsDb/_GrampsDbWriteXML.py (write_media_list): Typo. diff --git a/src/plugins/TestcaseGenerator.py b/src/plugins/TestcaseGenerator.py index bbc82bb64..888abda95 100644 --- a/src/plugins/TestcaseGenerator.py +++ b/src/plugins/TestcaseGenerator.py @@ -87,6 +87,7 @@ class TestcaseGenerator(Tool.Tool): self.generated_places = [] self.generated_events = [] self.generated_families = [] + self.generated_notes = [] self.text_serial_number = 1 # If an active persons exists the generated tree is connected to that person @@ -1193,9 +1194,20 @@ class TestcaseGenerator(Tool.Tool): if isinstance(o,RelLib.Name): o.set_type( self.rand_type( RelLib.NameType())) + if isinstance(o,RelLib.Note): + o.set( self.rand_text(self.NOTE)) + o.set_format( choice( (RelLib.Note.FLOWED,RelLib.Note.FORMATTED))) + o.set_type( self.rand_type(RelLib.NoteType())) + if issubclass(o.__class__,RelLib._NoteBase.NoteBase): - o.set_note( self.rand_text(self.NOTE)) - o.set_note_format( choice( (True,False))) + while randint(0,1) == 1: + if not self.generated_notes or randint(0,10) == 1: + n = RelLib.Note() + self.fill_object(n) + self.db.add_note( n, self.trans) + self.generated_notes.append( n.get_handle()) + n_h = choice(self.generated_notes) + o.add_note(n_h) if isinstance(o,RelLib.Place): o.set_title( self.rand_text(self.SHORT)) @@ -1409,13 +1421,19 @@ class TestcaseGenerator(Tool.Tool): word = word + choice(syllables) if type == self.FIRSTNAME_MALE: word = word + choice(("a","e","i","o","u")) - elif type == self.NOTE: + if randint(0,3) == 1: + word = word.title() + if type == self.NOTE: + if randint(0,10) == 1: + word = "%s" % word + elif randint(0,10) == 1: + word = "%s" % word + elif randint(0,10) == 1: + word = "%s" % word if randint(0,20) == 1: word = word + "." elif randint(0,30) == 1: word = word + ".\n" - if randint(0,3) == 1: - word = word.title() result = result + word if type == self.LASTNAME: