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']))
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']))
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)
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))
def test_parse(self): plugin = Plugin() plugin.add_arg('-e', '--test', action='store_true') args = plugin.parser.parse_args(['-e']) self.assertTrue(args.test)
def test_parse_exceptions(self): plugin = Plugin() plugin.add_arg('threshold', type=Threshold) self.assertRaises(ArgumentParserError, plugin.parse_args, [])
def test_simple_ok(self): plugin = Plugin() plugin.add_result(OK, 'OK') self.assertEqual(plugin.get_message(), 'OK')
def test_simple_default(self): plugin = Plugin() self.assertEqual(plugin.get_message(), '')
def test_simple_ow(self): plugin = Plugin() plugin.add_result(OK, 'OK') plugin.add_result(WARNING, 'WARNING') self.assertEqual(plugin.get_code(), WARNING)
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)
def test_simple_critical(self): plugin = Plugin() plugin.add_result(CRITICAL, 'CRITICAL') self.assertEqual(plugin.get_code(), CRITICAL)
def test_simple_default(self): plugin = Plugin() self.assertEqual(plugin.get_code(), UNKNOWN)