Exemplo n.º 1
0
 def test_bin_valuelist(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListEnum(['OKVal', 'OKVal', 'WarningVal', 'WarningVal', 'CriticalVal'], okValues=['OKVal'], warningValues=['WarningVal'], criticalValues=['CriticalVal'], unknownValues=['UnknownVal'])
     self.assertEqual(len(eo.critical), 1)
     self.assertEqual(len(eo.warning), 2)
     self.assertEqual(len(eo.unknown), 0)
     self.assertEqual(eo.getExitCode(), 2)
Exemplo n.º 2
0
 def test_string(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListEnum('WarningVal', warningValues=['WarningVal'])
     self.assertEqual(len(eo.critical), 0)
     self.assertEqual(len(eo.warning), 1)
     self.assertEqual(len(eo.unknown), 0)
     self.assertEqual(eo.warning[0], "value is WarningVal")
     self.assertEqual(eo.getExitCode(), 1)
Exemplo n.º 3
0
 def test_emptyList(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListEnum([], emptyStatus="OK")
     self.assertEqual(len(eo.critical), 0)
     self.assertEqual(len(eo.warning), 0)
     self.assertEqual(len(eo.unknown), 0)
     self.assertEqual(eo.getExitCode(), 0)
     ev.evalListEnum([], emptyStatus="WARNING")
     self.assertEqual(eo.warning[0], "list is Empty")
     self.assertEqual(eo.getExitCode(), 1)
Exemplo n.º 4
0
    def test_unknownValues(self):
        eo = NagErrors()
        ev = NagEval(eo)
        ev.evalListEnum(['junkVal'], unknownValueStatus="OK")
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 0)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 0)

        ev.evalListEnum(['junkVal'], unknownValueStatus="WARNING")
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 1)
        
        ev.evalListEnum(['junkVal'], unknownValueStatus="CRITICAL")
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 2)
        
        ev.evalListEnum(['junkVal'])
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 1)
        self.assertEqual(eo.getExitCode(), 3)
Exemplo n.º 5
0
    def test_default(self):
        eo = NagErrors()
        ev = NagEval(eo)

        ev.evalListEnum(['Junk'], unknownValueStatus='OK')
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 0)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 0)

        ev.evalListEnum(['Junk'], unknownValueStatus='WARNING')
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 1)
        
        ev.evalListEnum(['Junk'], unknownValueStatus='CRITICAL')
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 2)
        
        ev.evalListEnum(['Junk'], unknownValueStatus='UNKNOWN')
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 1)
        self.assertEqual(eo.getExitCode(), 3)
Exemplo n.º 6
0
 def test_postfixText(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListEnum(['Warning'], warningValues=['Warning'], postfixText=" String")
     self.assertEqual(eo.warning[0], "value is Warning String")