Beispiel #1
0
 def test_simple_owc_level(self):
     plugin = Plugin()
     plugin.add_result(OK, 'OK')
     plugin.add_result(WARNING, 'WARNING')
     plugin.add_result(CRITICAL, 'CRITICAL')
     self.assertEqual(plugin.get_message(joiner=', ', msglevels=[WARNING]),
                      ', '.join(['WARNING']))
Beispiel #2
0
 def test_simple(self):
     plugin = Plugin()
     plugin.add_extdata('OK')
     plugin.add_extdata('hey!')
     plugin.add_extdata('STUFF')
     self.assertEqual(plugin.get_extdata(),
                      '\n'.join(['OK', 'hey!', 'STUFF']))
Beispiel #3
0
 def test_simple_cw(self):
     plugin = Plugin()
     plugin.add_result(CRITICAL, 'OK')
     plugin.add_result(WARNING, 'WARNING')
     plugin.add_result(WARNING, 'WARNING')
     plugin.add_result(WARNING, 'WARNING')
     plugin.add_result(WARNING, 'UNKNOWN')
     self.assertEqual(plugin.get_code(), CRITICAL)
Beispiel #4
0
 def test_parse_threshold_native(self):
     plugin = Plugin()
     plugin.add_arg('-w', '--warning-threshold', type=Threshold)
     plugin.add_arg('-c', '--critical-threshold', type=Threshold)
     args = plugin.parse_args(['-w', '10:20', '-c', '0:40'])
     self.assertEqual(OK, plugin.check_threshold(15,
                                                 args.warning_threshold,
                                                 args.critical_threshold))
Beispiel #5
0
 def test_parse(self):
     plugin = Plugin()
     plugin.add_arg('-e', '--test', action='store_true')
     args = plugin.parser.parse_args(['-e'])
     self.assertTrue(args.test)
Beispiel #6
0
 def test_parse_exceptions(self):
     plugin = Plugin()
     plugin.add_arg('threshold', type=Threshold)
     self.assertRaises(ArgumentParserError, plugin.parse_args, [])
Beispiel #7
0
 def test_simple_ok(self):
     plugin = Plugin()
     plugin.add_result(OK, 'OK')
     self.assertEqual(plugin.get_message(), 'OK')
Beispiel #8
0
 def test_simple_default(self):
     plugin = Plugin()
     self.assertEqual(plugin.get_message(), '')
Beispiel #9
0
 def test_simple_ow(self):
     plugin = Plugin()
     plugin.add_result(OK, 'OK')
     plugin.add_result(WARNING, 'WARNING')
     self.assertEqual(plugin.get_code(), WARNING)
Beispiel #10
0
 def test_simple_owc(self):
     plugin = Plugin()
     plugin.add_result(OK, 'OK')
     plugin.add_result(WARNING, 'WARNING')
     plugin.add_result(CRITICAL, 'CRITICAL')
     self.assertEqual(plugin.get_code(), CRITICAL)
Beispiel #11
0
 def test_simple_critical(self):
     plugin = Plugin()
     plugin.add_result(CRITICAL, 'CRITICAL')
     self.assertEqual(plugin.get_code(), CRITICAL)
Beispiel #12
0
 def test_simple_default(self):
     plugin = Plugin()
     self.assertEqual(plugin.get_code(), UNKNOWN)