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