Exemple #1
0
    def test_default(self):
        eo = NagErrors()
        ev = NagEval(eo)

        ev.evalEnum('Junk', defaultStatus='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.evalEnum('Junk', defaultStatus='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.evalEnum('Junk', defaultStatus='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.evalEnum('Junk', defaultStatus='UNKNOWN')
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 1)
        self.assertEqual(eo.getExitCode(), 3)
Exemple #2
0
 def test_postfixText(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalEnum('Warning', warningValues=['Warning'], postfixText=" String")
     self.assertEqual(eo.warning[0], "value is Warning String")
Exemple #3
0
 def test_prefixText(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalEnum('Warning', warningValues=['Warning'], prefixText="Test ")
     self.assertEqual(eo.warning[0], "Test value is Warning")
Exemple #4
0
    def test_bin_value(self):
        eo = NagErrors()
        ev = NagEval(eo)

        ev.evalEnum('OKVal', okValues=['OKVal'])
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 0)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 0)

        ev.evalEnum('WarningVal', warningValues=['WarningVal'])
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 1)
        
        ev.evalEnum('CriticalVal', criticalValues=['CriticalVal'])
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 2)
        
        ev.evalEnum('UnknownVal', unknownValues=['UnknownVal'])
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 1)
        self.assertEqual(eo.getExitCode(), 3)

        eo = NagErrors()
        ev = NagEval(eo)
        ev.evalEnum('OKVal', okValues=['OKVal'], warningValues=['WarningVal'], criticalValues=['CriticalVal'], unknownValues=['UnknownVal'])
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 0)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 0)

        ev.evalEnum('WarningVal', okValues=['OKVal'], warningValues=['WarningVal'], criticalValues=['CriticalVal'], unknownValues=['UnknownVal'])
        self.assertEqual(len(eo.critical), 0)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 1)
        
        ev.evalEnum('CriticalVal', okValues=['OKVal'], warningValues=['WarningVal'], criticalValues=['CriticalVal'], unknownValues=['UnknownVal'])
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 0)
        self.assertEqual(eo.getExitCode(), 2)
        
        ev.evalEnum('UnknownVal', okValues=['OKVal'], warningValues=['WarningVal'], criticalValues=['CriticalVal'], unknownValues=['UnknownVal'])
        self.assertEqual(len(eo.critical), 1)
        self.assertEqual(len(eo.warning), 1)
        self.assertEqual(len(eo.unknown), 1)
        self.assertEqual(eo.getExitCode(), 3)