Example #1
0
 def testFullTriggerFalseBasedOnConfig(self):
     fh = open(CONFIG, 'w')
     fh.write('executor = ls -l\n')
     fh.close()
     properties = Property(CONFIG)
     properties.parse_properties()
     executor = notifications.Executor(properties)
     self.assertEqual(False, executor.full_trigger_active)
     executor.stop()
Example #2
0
 def testShouldNotifyWithNoFullTrigger(self):
     logcolor = LogColors()
     message = Message(logcolor)
     log = Log('anylog')
     logpath = log.path
     command = 'echo'
     properties = PropertiesStub(command)
     trace = "this is a fatal log trace"
     executor = notifications.Executor(properties,
                                       trigger_executor=TriggerExecutorStub)
     trigger = executor._build_trigger(trace, logpath)
     self.assertEqual(['echo'], trigger)
Example #3
0
 def testShouldNotExecuteIfLevelNotInPullers(self):
     logcolor = LogColors()
     message = Message(logcolor)
     log = Log('anylog')
     command = 'anything %s %s'
     trace = "this is an info log trace"
     properties = PropertiesStub(command)
     executor = notifications.Executor(properties,
                                       trigger_executor=TriggerExecutorStub)
     message.parse(trace, log)
     executor.notify(message, log)
     len_captured_lines = len(sys.stdout.captured)
     self.assertEqual(len_captured_lines, 0)
Example #4
0
 def testShouldExecuteIfTargetMessage(self):
     logcolor = LogColors()
     logfile = 'anylog'
     log = Log(logfile)
     command = "echo %s %s"
     trace = "this is an info log trace"
     trigger = ['echo', trace, logfile]
     properties = PropertiesStub(command)
     message = Message(logcolor, target='trace')
     message.parse(trace, log)
     executor = notifications.Executor(properties,
                                       trigger_executor=TriggerExecutorStub)
     executor.notify(message, log)
     self.assertEqual(TriggerExecutorStub.execute_msg,
                      sys.stdout.captured[0])
Example #5
0
 def testShouldProvideNotifyMethod(self):
     command = "ls -l"
     properties = PropertiesStub(command)
     executor = notifications.Executor(properties)
     self.assertTrue(hasattr(executor, 'notify'))
Example #6
0
 def testShouldReadExecutorFromConfigFile(self):
     command = "ls -l"
     properties = PropertiesStub(command)
     executor = notifications.Executor(properties)
     self.assertEquals(['ls', '-l'], executor.executable)