Beispiel #1
0
 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')
Beispiel #2
0
 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')
Beispiel #3
0
    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)
        gaptime = 0.1
        resume.setAnalyticsGapNotification(gaptime)
        resume.notification_type(reportfileFullPath)
        fh = open('out.log')
        lines = fh.readlines()
        fh.close()
        logcolors = LogColors()
        msg = Message(logcolors)

        def overgap():
            return gaptime + 1

        def belowgap():
            return gaptime - 0.01

        resume.timer.inactivityEllapsed = overgap

        for line in lines:
            msg.parse(line, log)
            resume.update(msg, log)
            resume.timer.inactivityEllapsed = belowgap
        fh = open(reportfileFullPath)
        reportlength = len(fh.readlines())
        fh.close()
        os.remove(reportfileFullPath)
        self.assertEquals(24, reportlength)
        os.remove('aconfig')
Beispiel #4
0
    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)
        gaptime = 0.1
        resume.setAnalyticsGapNotification(gaptime)
        resume.notification_type(reportfileFullPath)
        fh = open('out.log')
        lines = fh.readlines()
        fh.close()
        logcolors = LogColors()
        msg = Message(logcolors)

        def overgap():
            return gaptime + 1

        def belowgap():
            return gaptime - 0.01

        resume.timer.inactivityEllapsed = overgap

        for line in lines:
            msg.parse(line, log)
            resume.update(msg, log)
            resume.timer.inactivityEllapsed = belowgap
        fh = open(reportfileFullPath)
        reportlength = len(fh.readlines())
        fh.close()
        os.remove(reportfileFullPath)
        self.assertEquals(24, reportlength)
        os.remove('aconfig')