Ejemplo n.º 1
0
 def testResumeBuilderWithInactivityAction(self):
     defaults = getDefaults()
     defaults.actions = [notifications.Inactivity(5)]
     tailer = LogTailer(defaults)
     resume = tailer.resumeBuilder()
     self.assertTrue(
         isinstance(resume.notifiers[0], notifications.Inactivity))
Ejemplo n.º 2
0
 def testshouldReturnTrueifMailAlreadyinMailAction(self):
     mailaction_mock = self.mocker.mock(notifications.Mail)
     self.mocker.replay()
     defaults = getDefaults()
     defaults.actions = [mailaction_mock]
     logtailer = LogTailer(defaults)
     self.assertEqual(True, logtailer.mailIsSetup())
Ejemplo n.º 3
0
 def testPipeOutShouldSendMessageParseThreeParams(self):
     sys.stdin = ['error > one error', 'warning > one warning']
     sys.stdout = MemoryWriter()
     defaults = getDefaults()
     defaults.actions.append(notifications.Print())
     logtailer = LogTailer(defaults)
     logtailer.pipeOut()
     self.assertTrue('error > one error' in sys.stdout.captured[0])
Ejemplo n.º 4
0
 def testshouldReturnFalseMailNotSetup(self):
     self._setupAConfig()
     properties = Property('aconfig')
     properties.parse_properties()
     defaults = getDefaults()
     defaults.properties = properties
     logtailer = LogTailer(defaults)
     self.assertEqual(False, logtailer.mailIsSetup())
Ejemplo n.º 5
0
 def test_daemonized_resumedaemonizedtrue(self):
     default_config = getDefaults()
     default_config.silence = True
     logtailer = LogTailer(default_config)
     resumeObj = logtailer.resumeBuilder()
     self.assertTrue(isinstance(resumeObj, reporting.Resume))
     self.assertEquals('print', resumeObj.getNotificationType())
     self.assertTrue(resumeObj.is_daemonized)
Ejemplo n.º 6
0
 def testResumeBuilderWithAnalyticsFile(self):
     sys.stdout = MemoryWriter()
     reportfile = 'reportfile.txt'
     configfile = 'aconfig'
     fh = open(configfile, 'w')
     fh.write('analyticsnotification = ' + reportfile + '\n')
     fh.close()
     properties = Property(configfile)
     properties.parse_properties()
     defaults = getDefaults()
     defaults.properties = properties
     logtailer = LogTailer(defaults)
     resumeObj = logtailer.resumeBuilder()
     self.assertTrue(isinstance(resumeObj, reporting.Resume))
     self.assertEquals('file', resumeObj.getNotificationType())
     self.assertEquals(reportfile, resumeObj.report_file)
Ejemplo n.º 7
0
    def test_tailerPrintAction(self):
        onelogtrace = 'this is an info log trace'
        anotherlogtrace = 'this is a debug log trace'

        def write_log():
            fh = open(self.log_name, 'a')
            fh.write(onelogtrace + '\n')
            fh.write(anotherlogtrace + '\n')
            fh.close()
            self.raise_count += 1

        def wait_for(secs):
            if self.raise_count == 0:
                write_log()
                return
            raise KeyboardInterrupt

        sys.stdout = MemoryWriter()
        tailer = LogTailer(getDefaults(), wait_for)
        tailer.addLog(self.onelog)
        tailer.tailer()
        finish_trace = re.compile(r'because colors are fun')
        found = False
        for _, line in enumerate(sys.stdout.captured):
            if finish_trace.search(line):
                found = True
        if not found:
            self.fail()
Ejemplo n.º 8
0
 def testReturnsFalseMailOrInactivityActionNotificationNotEnabled(self):
     logtailer = LogTailer(getDefaults())
     self.assertEqual(False, logtailer.mailIsSetup())