Esempio n. 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')
Esempio n. 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')
Esempio n. 3
0
 def testTargetsNoColors(self):
     fh = open('config.txt','w')
     regexes = "log$; ^2009-10-12 got something here$"
     targetsline = "targets /var/log/messages = "+regexes+"\n"
     fh.write(targetsline)
     fh.close()
     property = Property('config.txt')
     property.parse_properties()
     self.assertEqual(regexes, 
                      property.get_value('targets /var/log/messages'))
     log = Log('/var/log/messages', property)
     color = log.logTargetColor.get(re.compile('log$'))
     self.assertFalse(color)
     os.remove('config.txt')
Esempio n. 4
0
 def testshouldHaveitsOwnTargetSchemesIfProvidedInConfigFile(self):
     fh = open('config.txt','w')
     regexesColors = ("log$ : yellow, on_cyan; ^2009-10-12 got something "
         "here$ : black, on_cyan")
     targetsline = "targets /var/log/messages = "+regexesColors+"\n"
     fh.write(targetsline)
     fh.close()
     property = Property('config.txt')
     property.parse_properties()
     self.assertEqual(regexesColors, 
                      property.get_value('targets /var/log/messages'))
     log = Log('/var/log/messages', property)
     logTargetsColors = {re.compile('log$'): 'yellow, on_cyan',
         re.compile("^2009-10-12 got something here$") : 'black, on_cyan'}
     self.assertEqual(logTargetsColors, log.logTargetColor)
     os.remove('config.txt')