Add test case for key_value_list_unknown

This commit is contained in:
Markus Opolka 2020-03-03 11:59:36 +01:00
parent 95912246a2
commit 375da5d605

View File

@ -59,6 +59,10 @@ class RulesHelper:
self.key_value_list_not_critical = data self.key_value_list_not_critical = data
return self return self
def dash_U(self, data):
self.key_value_list_unknown = data
return self
def dash_w(self, data): def dash_w(self, data):
self.key_threshold_warning = data self.key_threshold_warning = data
return self return self
@ -82,6 +86,7 @@ class UtilTest(unittest.TestCase):
nagios.append_warning(processor.checkWarning()) nagios.append_warning(processor.checkWarning())
nagios.append_critical(processor.checkCritical()) nagios.append_critical(processor.checkCritical())
nagios.append_metrics(processor.checkMetrics()) nagios.append_metrics(processor.checkMetrics())
nagios.append_unknown(processor.checkUnknown())
self.assertEqual(code, nagios.getCode()) self.assertEqual(code, nagios.getCode())
def test_metrics(self): def test_metrics(self):
@ -98,6 +103,10 @@ class UtilTest(unittest.TestCase):
self.check_data(RulesHelper().dash_m(['(*).value,s,1:5,1:5']), self.check_data(RulesHelper().dash_m(['(*).value,s,1:5,1:5']),
'[{"value": 5},{"value": 100}]', CRITICAL_CODE) '[{"value": 5},{"value": 100}]', CRITICAL_CODE)
def test_unknown(self):
self.check_data(RulesHelper().dash_U(['metric,0']),
'{"metric": 3}', UNKNOWN_CODE)
def test_exists(self): def test_exists(self):
self.check_data(RulesHelper().dash_e(['nothere']), self.check_data(RulesHelper().dash_e(['nothere']),
'{"metric": 5}', WARNING_CODE) '{"metric": 5}', WARNING_CODE)