def test_toMonthname(self): result="Sep\w*" from comoonics.search.datetime.TimeExpression import TimeExpression monthnum=9 monthname=TimeExpression.toMonthname(monthnum, False) print "Mtimeonth %u: %s" %(monthnum, monthname) self.assertEquals(monthname, result, "Monthnum %u is not %s as expected. %s" %(monthnum, monthname, result))
def test_SyslogDateFormat_format(self): from comoonics.search.datetime.TimeExpression import SyslogDateFormat, TimeExpression now=self.now() results=["(?P<month>Jan\w*|Feb\w*|Mar\w*|Apr\w*|Mai|Jun\w*|Jul\w*|Aug\w*|Sep\w*|Oct\w*)\s+(?P<day>\d{1,2}) (?P<hour>16):(?P<minute>\d{1,2}):(?P<second>\d{1,2})", "(?P<month>Sep\w*)\s+(?P<day>\d{1,2}) (?P<hour>04):(?P<minute>\d{1,2}):(?P<second>\d{1,2})", "(?P<month>%s)\s+(?P<day>%s) (?P<hour>%s):(?P<minute>%s):(?P<second>\d{1,2})" %(TimeExpression.toMonthname(now[1], False), now[2], now[3], now[4]), "(?P<month>Jun\w*)\s+(?P<day>25) (?P<hour>\d{1,2}):(?P<minute>\d{1,2}):(?P<second>\d{1,2})", "(?P<month>Jan\w*|Feb\w*|Mar\w*|Apr\w*|Mai|Jun\w*|Jul\w*|Aug\w*|Sep\w*|Oct\w*|Nov\w*|Dec\w*)\s+(?P<day>\d{1,2}) (?P<hour>\d{1,2}):(?P<minute>\d{1,2}):(?P<second>\d{1,2})"] for i in range(len(self.formater_teststrs)): self.basetest_Formater_format(SyslogDateFormat(), self.formater_teststrs[i], results[i])