def testReportToAFile(self): reportfileFullPath = "reportfile.txt" fh = open('aconfig','w') fh.write('analyticsnotification = '+ reportfileFullPath +'\n') fh.write('analyticsgaptime = 0.1\n') fh.close() properties = Property('aconfig') properties.parse_properties() self.assertTrue(properties.is_key('analyticsnotification')) log = Log('out.log') arrayLog = [log] resume = reporting.Resume(arrayLog) resume.setAnalyticsGapNotification(0.1) resume.notification_type(reportfileFullPath) fh = open('out.log') lines = fh.readlines() fh.close() logcolors = LogColors() msg = Message(logcolors) time.sleep(0.1) for line in lines: msg.parse(line, log) resume.update(msg, log) fh = open(reportfileFullPath) reportlength = len(fh.readlines()) fh.close() os.remove(reportfileFullPath) self.assertEquals(22, reportlength) os.remove('aconfig')
def testShouldSetupMailNotificationIfAnalyticsNotificationIsSetup(self): fh = open('aconfig','w') fh.write('analyticsnotification = mail\n') fh.write('analyticsgaptime = 3600\n') fh.close() properties = Property('aconfig') properties.parse_properties() self.assertTrue(properties.is_key('analyticsnotification')) arrayLog = [Log('out.log')] resume = reporting.Resume(arrayLog) mailactionmocker = mox.Mox() mailaction = mailactionmocker.CreateMock(notifications.Mail) if properties.get_value('analyticsnotification') == 'mail': resume.setMailNotification(mailaction) self.assertEquals('mail',resume.getNotificationType()) gaptime = properties.get_value('analyticsgaptime') if gaptime: resume.setAnalyticsGapNotification(gaptime) self.assertEquals(3600,int(resume.getGapNotificationTime())) os.remove('aconfig')