예제 #1
0
 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')
예제 #2
0
    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))
예제 #3
0
 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'
     )
예제 #4
0
    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)
        )
예제 #5
0
 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)
     )
예제 #6
0
 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)
     )
예제 #7
0
 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%'))
예제 #8
0
 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%'))