mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2026-02-05 22:55:15 +01:00
Add value_separator option to specify how JSON values are being split
- Fixes issue 43
This commit is contained in:
@@ -27,3 +27,8 @@ class ArgsTest(unittest.TestCase):
|
||||
def test_parser_with_port(self):
|
||||
parser = parseArgs(['-H', 'foobar', '-P', '8888'])
|
||||
self.assertEqual(parser.port, '8888')
|
||||
|
||||
def test_parser_with_separator(self):
|
||||
parser = parseArgs(['-H', 'foobar', '-f', '_', '-F', '_'])
|
||||
self.assertEqual(parser.separator, '_')
|
||||
self.assertEqual(parser.value_separator, '_')
|
||||
|
||||
@@ -19,6 +19,7 @@ UNKNOWN_CODE = 3
|
||||
|
||||
class RulesHelper:
|
||||
separator = '.'
|
||||
value_separator = ':'
|
||||
debug = False
|
||||
key_threshold_warning = None
|
||||
key_value_list = None
|
||||
@@ -123,6 +124,17 @@ class UtilTest(unittest.TestCase):
|
||||
self.check_data(RulesHelper().dash_q(['metric,5']),
|
||||
'{"metric": 5}', OK_CODE)
|
||||
|
||||
def test_equality_colon(self):
|
||||
"""
|
||||
See https://github.com/drewkerrigan/nagios-http-json/issues/43
|
||||
"""
|
||||
rules = RulesHelper()
|
||||
rules.value_separator = '_'
|
||||
|
||||
# This should not fail
|
||||
self.check_data(rules.dash_q(['metric,foo:bar']),
|
||||
'{"metric": "foo:bar"}', OK_CODE)
|
||||
|
||||
def test_non_equality(self):
|
||||
self.check_data(RulesHelper().dash_y(['metric,6']),
|
||||
'{"metric": 6}', WARNING_CODE)
|
||||
|
||||
Reference in New Issue
Block a user