src/plugins/TestcaseGenerator.py now tests date display and date parsing too

svn: r4563
This commit is contained in:
Martin Hawlisch 2005-05-12 08:28:49 +00:00
parent 39addc1b9b
commit 3966f768f7
2 changed files with 32 additions and 6 deletions

View File

@ -1,6 +1,7 @@
2005-05-12 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-05-12 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/TestcaseGenerator.py: Added generation of multiple date * src/plugins/TestcaseGenerator.py: Added generation of multiple date
formats including invalid dates. formats including invalid dates. This is displaying and reparsing every
date to compare the result.
* src/plugins/NavWebPage.py (HomePage): Dont crash on note only object * src/plugins/NavWebPage.py (HomePage): Dont crash on note only object
* src/dates/Date_de.py: Updated translation * src/dates/Date_de.py: Updated translation

View File

@ -30,6 +30,8 @@
import os import os
import re import re
import time import time
import traceback
import sys
from random import randint,choice from random import randint,choice
from gettext import gettext as _ from gettext import gettext as _
@ -54,6 +56,7 @@ import Utils
import const import const
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
from DateHandler import parser as _dp from DateHandler import parser as _dp
from DateHandler import displayer as _dd
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -439,13 +442,35 @@ class TestcaseGenerator:
# now add them as birth to new persons # now add them as birth to new persons
for dateval in dates: for dateval in dates:
event = RelLib.Event() bevent = RelLib.Event()
event.set_name("Birth") bevent.set_name("Birth")
event.set_date_object(dateval) bevent.set_date_object(dateval)
event_h = self.db.add_event(event,self.trans) bevent_h = self.db.add_event(bevent,self.trans)
# for the death event display the date as text and parse it back to a new date
ndate = None
try:
datestr = _dd.display( dateval)
print datestr
try:
ndate = _dp.parse( datestr)
if not ndate:
ndate = Date.Date()
ndate.set_as_text("DateParser None")
except:
ndate = Date.Date()
ndate.set_as_text("DateParser Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
except:
ndate = Date.Date()
ndate.set_as_text("DateDisplay Exception: %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
devent = RelLib.Event()
devent.set_name("Death")
devent.set_date_object(ndate)
devent_h = self.db.add_event(devent,self.trans)
person_h = self.generate_person(None, "DateTest") person_h = self.generate_person(None, "DateTest")
person = self.db.get_person_from_handle(person_h) person = self.db.get_person_from_handle(person_h)
person.set_birth_handle(event_h) person.set_birth_handle(bevent_h)
person.set_death_handle(devent_h)
self.db.commit_person(person,self.trans) self.db.commit_person(person,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP self.commit_transaction() # COMMIT TRANSACTION STEP