Enhance Date Parser Display Test debug tool
Test for both Julian and Gregorian dates. Add translated strings already used elsewhere.
This commit is contained in:
parent
417a65f721
commit
91473e65fb
@ -75,7 +75,6 @@ class DateParserDisplayTest(tool.Tool):
|
|||||||
self.parent_window = None
|
self.parent_window = None
|
||||||
self.run_tool()
|
self.run_tool()
|
||||||
|
|
||||||
|
|
||||||
def run_tool(self):
|
def run_tool(self):
|
||||||
self.progress = ProgressMeter(_('Running Date Test'), '',
|
self.progress = ProgressMeter(_('Running Date Test'), '',
|
||||||
parent=self.parent_window)
|
parent=self.parent_window)
|
||||||
@ -83,53 +82,54 @@ class DateParserDisplayTest(tool.Tool):
|
|||||||
4)
|
4)
|
||||||
dates = []
|
dates = []
|
||||||
# first some valid dates
|
# first some valid dates
|
||||||
calendar = Date.CAL_GREGORIAN
|
d_year = 1789
|
||||||
for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED,
|
for calendar in (Date.CAL_GREGORIAN, Date.CAL_JULIAN):
|
||||||
Date.QUAL_CALCULATED):
|
for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED,
|
||||||
for modifier in (Date.MOD_NONE, Date.MOD_BEFORE,
|
Date.QUAL_CALCULATED):
|
||||||
Date.MOD_AFTER, Date.MOD_ABOUT):
|
for modifier in (Date.MOD_NONE, Date.MOD_BEFORE,
|
||||||
for slash1 in (False,True):
|
Date.MOD_AFTER, Date.MOD_ABOUT):
|
||||||
for month in range(0,13):
|
for slash1 in (False,True):
|
||||||
for day in (0,5,27):
|
|
||||||
if not month and day:
|
|
||||||
continue
|
|
||||||
d = Date()
|
|
||||||
d.set(quality,modifier,calendar,(day,month,1789,slash1),"Text comment")
|
|
||||||
dates.append( d)
|
|
||||||
for modifier in (Date.MOD_RANGE, Date.MOD_SPAN):
|
|
||||||
for slash1 in (False,True):
|
|
||||||
for slash2 in (False,True):
|
|
||||||
for month in range(0,13):
|
for month in range(0,13):
|
||||||
for day in (0,5,27):
|
for day in (0,5,27):
|
||||||
if not month and day:
|
if not month and day:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
d = Date()
|
d = Date()
|
||||||
d.set(quality,modifier,calendar,(day,month,1789,slash1,day,month,1876,slash2),"Text comment")
|
d.set(quality,modifier,calendar,(day,month,d_year,slash1),"Text comment")
|
||||||
dates.append( d)
|
dates.append( d)
|
||||||
|
|
||||||
if not month:
|
for modifier in (Date.MOD_RANGE, Date.MOD_SPAN):
|
||||||
continue
|
for slash1 in (False,True):
|
||||||
|
for slash2 in (False,True):
|
||||||
|
for month in range(0,13):
|
||||||
|
for day in (0,5,27):
|
||||||
|
if not month and day:
|
||||||
|
continue
|
||||||
|
|
||||||
d = Date()
|
d = Date()
|
||||||
d.set(quality,modifier,calendar,(day,month,1789,slash1,day,13-month,1876,slash2),"Text comment")
|
d.set(quality,modifier,calendar,(day,month,d_year,slash1,day,month,(d_year + 87),slash2),"Text comment")
|
||||||
dates.append( d)
|
dates.append( d)
|
||||||
|
|
||||||
if not day:
|
if not month:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
d = Date()
|
d = Date()
|
||||||
d.set(quality,modifier,calendar,(day,month,1789,slash1,32-day,month,1876,slash2),"Text comment")
|
d.set(quality,modifier,calendar,(day,month,d_year,slash1,day,13-month,(d_year + 87),slash2),"Text comment")
|
||||||
dates.append( d)
|
dates.append( d)
|
||||||
d = Date()
|
|
||||||
d.set(quality,modifier,calendar,(day,month,1789,slash1,32-day,13-month,1876,slash2),"Text comment")
|
if not day:
|
||||||
dates.append( d)
|
continue
|
||||||
modifier = Date.MOD_TEXTONLY
|
|
||||||
d = Date()
|
d = Date()
|
||||||
d.set(quality,modifier,calendar,Date.EMPTY,
|
d.set(quality,modifier,calendar,(day,month,d_year,slash1,32-day,month,(d_year + 87),slash2),"Text comment")
|
||||||
"This is a textual date")
|
dates.append( d)
|
||||||
dates.append( d)
|
d = Date()
|
||||||
self.progress.step()
|
d.set(quality,modifier,calendar,(day,month,d_year,slash1,32-day,13-month,(d_year + 87),slash2),"Text comment")
|
||||||
|
dates.append( d)
|
||||||
|
modifier = Date.MOD_TEXTONLY
|
||||||
|
d = Date()
|
||||||
|
d.set(quality,modifier,calendar,Date.EMPTY, "This is a textual date")
|
||||||
|
dates.append( d)
|
||||||
|
self.progress.step()
|
||||||
|
|
||||||
# test invalid dates
|
# test invalid dates
|
||||||
#dateval = (4,7,1789,False,5,8,1876,False)
|
#dateval = (4,7,1789,False,5,8,1876,False)
|
||||||
@ -192,16 +192,16 @@ class DateParserDisplayTest(tool.Tool):
|
|||||||
for dateval in dates:
|
for dateval in dates:
|
||||||
person = Person()
|
person = Person()
|
||||||
surname = Surname()
|
surname = Surname()
|
||||||
surname.set_surname("DateTest")
|
surname.set_surname(_("Person"))
|
||||||
name = Name()
|
name = Name()
|
||||||
name.add_surname(surname)
|
name.add_surname(surname)
|
||||||
name.set_first_name("Test %d" % i)
|
name.set_first_name("{:04d}".format(i))
|
||||||
person.set_primary_name(name)
|
person.set_primary_name(name)
|
||||||
self.db.add_person(person, self.trans)
|
self.db.add_person(person, self.trans)
|
||||||
bevent = Event()
|
bevent = Event()
|
||||||
bevent.set_type(EventType.BIRTH)
|
bevent.set_type(EventType.BIRTH)
|
||||||
bevent.set_date_object(dateval)
|
bevent.set_date_object(dateval)
|
||||||
bevent.set_description("Date Test %d (source)" % i)
|
bevent.set_description(_("Source"))
|
||||||
bevent_h = self.db.add_event(bevent, self.trans)
|
bevent_h = self.db.add_event(bevent, self.trans)
|
||||||
bevent_ref = EventRef()
|
bevent_ref = EventRef()
|
||||||
bevent_ref.set_reference_handle(bevent_h)
|
bevent_ref.set_reference_handle(bevent_h)
|
||||||
@ -219,7 +219,7 @@ class DateParserDisplayTest(tool.Tool):
|
|||||||
person.add_tag(pass_handle)
|
person.add_tag(pass_handle)
|
||||||
except:
|
except:
|
||||||
ndate = Date()
|
ndate = Date()
|
||||||
ndate.set_as_text("DateParser Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
|
ndate.set_as_text("DateParser Exception: %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
|
||||||
person.add_tag(fail_handle)
|
person.add_tag(fail_handle)
|
||||||
else:
|
else:
|
||||||
person.add_tag(pass_handle)
|
person.add_tag(pass_handle)
|
||||||
@ -241,7 +241,7 @@ class DateParserDisplayTest(tool.Tool):
|
|||||||
devent = Event()
|
devent = Event()
|
||||||
devent.set_type(EventType.DEATH)
|
devent.set_type(EventType.DEATH)
|
||||||
devent.set_date_object(ndate)
|
devent.set_date_object(ndate)
|
||||||
devent.set_description("Date Test %d (result)" % i)
|
devent.set_description(_("Destination"))
|
||||||
devent_h = self.db.add_event(devent, self.trans)
|
devent_h = self.db.add_event(devent, self.trans)
|
||||||
devent_ref = EventRef()
|
devent_ref = EventRef()
|
||||||
devent_ref.set_reference_handle(devent_h)
|
devent_ref.set_reference_handle(devent_h)
|
||||||
|
Loading…
Reference in New Issue
Block a user