def test_parseErrorlog_empty_empty(self): #init job_name = None build_num = None task_name = None txt_expect = None instream = [] printed = [] mock = lambda *args, **kwargs: printed.append(args[0]) #exec parse_errorlog(instream,job_name,build_num,task_name,mprint=mock) #eval self.assertEqual(len(printed),0, "'{0}'!='{1}'".format(len(printed),0))
def test_parseErrorlog_startEnd_empty(self): #init job_name = "Testjob" build_num = 123 task_name = "Testtask" txt_expect = "" instream = [ "----------[START:{0}({1})]----------".format(job_name,build_num), "----------[END:{0}({1})]----------".format(job_name,build_num) ] printed = [] mock = lambda *args, **kwargs: printed.append(args[0]) #exec parse_errorlog(instream,job_name,build_num,task_name,mprint=mock) #eval self.assertEqual(len(printed),0, "'{0}'!='{1}'".format(len(printed),0))
def test_parseErrorlog_complex_complex(self): #init job_name = None build_num = None task_name = None jobname_expect = "Testjob" buildnum_expect = 123 msg1_expect = "testtext 1 abc" msg2_expect = "testtext 2 def" task2_expect = "testtask" warncount_expect = 1 errcount_expect = 1 output_expect = [ json.dumps(make_notification(jobname_expect,buildnum_expect,TYPE_WARNING,TASK_START,msg1_expect),sort_keys=True), json.dumps(make_notification(jobname_expect,buildnum_expect,TYPE_ERROR,task2_expect,msg2_expect),sort_keys=True), json.dumps(make_count(jobname_expect,buildnum_expect,TYPE_WARN_COUNT,warncount_expect),sort_keys=True), json.dumps(make_count(jobname_expect,buildnum_expect,TYPE_ERROR_COUNT,errcount_expect),sort_keys=True) ] instream = [ "----------[START:{0}({1})]----------".format(jobname_expect,buildnum_expect), "", "[{0}]".format(TASK_START), "WARNING: {0}".format(msg1_expect), "[{0}]".format(task2_expect), "ERROR: {0}".format(msg2_expect), "", "Warning count: {0}".format(warncount_expect), "Error count: {0}".format(errcount_expect), "----------[END:{0}({1})]----------".format(jobname_expect,buildnum_expect) ] printed = [] mock = lambda *args, **kwargs: printed.append(args[0]) #exec parse_errorlog(instream,job_name,build_num,task_name,mprint=mock) #eval self.assertEqual(printed,output_expect, "'{0}'!='{1}'".format(printed,output_expect)) def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(TestToJson)