Exemplo n.º 1
0
 def test_addCritical(self):
     eo = NagErrors()
     eo.addCritical('Critical Error')
     self.assertEqual(len(eo.critical), 1)
     self.assertEqual(len(eo.warning), 0)
     self.assertEqual(len(eo.unknown), 0)
     self.assertEqual(eo.getExitCode(), 2)
Exemplo n.º 2
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.º 3
0
 def test_string(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberAsc(50, warningAbove=25, criticalAbove=100)
     self.assertEqual(len(eo.critical), 0)
     self.assertEqual(len(eo.warning), 1)
     self.assertEqual(len(eo.unknown), 0)
     self.assertEqual(eo.warning[0], "50 is > 25")
     self.assertEqual(eo.getExitCode(), 1)
Exemplo n.º 4
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.º 5
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.º 6
0
 def test_mid(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalNumberDesc(45, warningBelow=50, criticalBelow=40)
     self.assertEqual(eo.getExitCode(), 1)
Exemplo n.º 7
0
 def test_prefixText(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberAsc([45], warningAbove=40, postfixText=" Units")
     self.assertEqual(eo.warning[0], "45 is > 40 Units")
Exemplo n.º 8
0
 def test_numberUnits(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberAsc([45], warningAbove=40, numberUnits="sec")
     self.assertEqual(eo.warning[0], "45sec is > 40sec")
Exemplo n.º 9
0
 def test_swappedTresholds(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberAsc([51], warningAbove=50, criticalAbove=40)
     self.assertEqual(eo.getExitCode(), 2)
Exemplo n.º 10
0
 def test_formatStatus(self):
     eo = NagErrors()
     self.assertEqual(eo.formatStatus('WARNING', ['String1']),
                      "WARNING String1\r\n")
     self.assertEqual(eo.formatStatus('WARNING', ['String1', 'String2']),
                      "WARNING:\r\n    String1\r\n    String2\r\n")
Exemplo n.º 11
0
 def test_high(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberDesc([55], warningBelow=50, criticalBelow=40)
     self.assertEqual(eo.getExitCode(), 0)
Exemplo n.º 12
0
 def test_prefixText(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalNumberAsc(45, warningAbove=40, prefixText="Test ")
     self.assertEqual(eo.warning[0], "Test 45 is > 40")
Exemplo n.º 13
0
 def test_negative_mid(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalNumberAsc(-8, warningAbove=-10, criticalAbove=-5)
     self.assertEqual(eo.getExitCode(), 1)
Exemplo n.º 14
0
 def test_mid(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalNumberAsc(45, warningAbove=40, criticalAbove=50)
     self.assertEqual(eo.getExitCode(), 1)
Exemplo n.º 15
0
 def test_negative_mid(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalNumberDesc(-8, warningBelow=-5, criticalBelow=-10)
     self.assertEqual(eo.getExitCode(), 1)
Exemplo n.º 16
0
 def test_high(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberAsc([55], warningAbove=40, criticalAbove=50)
     self.assertEqual(eo.getExitCode(), 2)
Exemplo n.º 17
0
 def test_prefixText(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalNumberDesc(45, warningBelow=50, prefixText="Test ")
     self.assertEqual(eo.warning[0], "Test 45 is < 50")
Exemplo n.º 18
0
 def test_negative_high(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberAsc([-3], warningAbove=-10, criticalAbove=-5)
     self.assertEqual(eo.getExitCode(), 2)
Exemplo n.º 19
0
 def test_negative_high(self):
     eo = NagErrors()
     ev = NagEval(eo)
     ev.evalListNumberDesc([-3], warningBelow=-5, criticalBelow=-10)
     self.assertEqual(eo.getExitCode(), 0)
Exemplo n.º 20
0
 def test_okStatus(self):
     eo = NagErrors()
     self.assertEqual(len(eo.critical), 0)
     self.assertEqual(len(eo.warning), 0)
     self.assertEqual(len(eo.unknown), 0)
     self.assertEqual(eo.getExitCode(), 0)