Exemple #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']))
Exemple #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']))
Exemple #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)
Exemple #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))
Exemple #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)
Exemple #6
0
 def test_parse_exceptions(self):
     plugin = Plugin()
     plugin.add_arg('threshold', type=Threshold)
     self.assertRaises(ArgumentParserError, plugin.parse_args, [])
Exemple #7
0
 def test_simple_ok(self):
     plugin = Plugin()
     plugin.add_result(OK, 'OK')
     self.assertEqual(plugin.get_message(), 'OK')
Exemple #8
0
 def test_simple_default(self):
     plugin = Plugin()
     self.assertEqual(plugin.get_message(), '')
Exemple #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)
Exemple #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)
Exemple #11
0
 def test_simple_critical(self):
     plugin = Plugin()
     plugin.add_result(CRITICAL, 'CRITICAL')
     self.assertEqual(plugin.get_code(), CRITICAL)
Exemple #12
0
 def test_simple_default(self):
     plugin = Plugin()
     self.assertEqual(plugin.get_code(), UNKNOWN)