def test_status_code_to_str(self): self.assertEqual(Plugin.status_code_to_str(Plugin.STATUS_OK), 'OK') self.assertEqual(Plugin.status_code_to_str(Plugin.STATUS_WARN), 'WARNING') self.assertEqual(Plugin.status_code_to_str(Plugin.STATUS_CRIT), 'CRITICAL') self.assertEqual(Plugin.status_code_to_str(Plugin.STATUS_UNKNOWN), 'UNKNOWN') self.assertEqual(Plugin.status_code_to_str(42), 'UNKNOWN')
def test_get_threshold(self): check_config = {'warn': 75, 'crit': 95, 'something_random': '10'} # Test without modifier self.assertTupleEqual((95, 75), Plugin.get_thresholds(check_config)) # Test with modifier def double(number): return number * 2 self.assertTupleEqual((190, 150), Plugin.get_thresholds(check_config, double))
def test_status_code_to_str(self): self.assertEquals(Plugin.status_code_to_str(Plugin.STATUS_OK), 'OK') self.assertEquals( Plugin.status_code_to_str(Plugin.STATUS_WARN), 'WARNING' ) self.assertEquals( Plugin.status_code_to_str(Plugin.STATUS_CRIT), 'CRITICAL' ) self.assertEquals( Plugin.status_code_to_str(Plugin.STATUS_UNKNOWN), 'UNKNOWN' ) self.assertEquals( Plugin.status_code_to_str(42), 'UNKNOWN' )
def test_get_threshold(self): check_config = { 'warn': 75, 'crit': 95, 'something_random': '10' } # Test without modifier self.assertTupleEqual((95, 75), Plugin.get_thresholds(check_config)) # Test with modifier def double(number): return number * 2 self.assertTupleEqual( (190, 150), Plugin.get_thresholds(check_config, double) )
def test_strip_percent_sign_from_check_config(self): check_config = { 'warn': '75%', 'crit': 95, 'something_random': '10' } expected_config = { 'warn': 75, 'crit': 95, 'something_random': '10' } self.assertDictEqual( expected_config, Plugin._strip_percent_sign_from_check_config(check_config) )
def test_strip_percent_sign(self): self.assertEqual(10, Plugin._strip_percent_sign('10')) self.assertEqual(10, Plugin._strip_percent_sign('10%')) self.assertEqual(-10, Plugin._strip_percent_sign('-10%'))
def test_strip_percent_sign(self): self.assertEquals(10, Plugin._strip_percent_sign('10')) self.assertEquals(10, Plugin._strip_percent_sign('10%')) self.assertEquals(-10, Plugin._strip_percent_sign('-10%'))