From 22699f7be1cb2f6a16cec80e5462df14f561c487 Mon Sep 17 00:00:00 2001 From: Jinping Han Date: Mon, 11 Feb 2019 09:24:46 -0800 Subject: [PATCH 1/2] https://github.com/StackStorm/orquesta/issues/119. Failure to publish `True` to a variable using `shorthand format` --- orquesta/utils/parameters.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/orquesta/utils/parameters.py b/orquesta/utils/parameters.py index 2083f59c..22a9c54a 100644 --- a/orquesta/utils/parameters.py +++ b/orquesta/utils/parameters.py @@ -22,8 +22,8 @@ REGEX_VALUE_IN_APOSTROPHES = "'[^']*'\s*" REGEX_FLOATING_NUMBER = '[-]?\d*\.\d+' REGEX_INTEGER = '[-]?\d+' -REGEX_TRUE = 'true' -REGEX_FALSE = 'false' +REGEX_TRUE = '(?i)true' +REGEX_FALSE = '(?i)false' REGEX_NULL = 'null' # REGEX_FLOATING_NUMBER must go before REGEX_INTEGER @@ -61,6 +61,9 @@ def parse_inline_params(s, preserve_order=True): v = re.sub("^'", '', v) v = re.sub("'$", '', v) + if v.lower() == 'true' or v.lower() == 'false': + v = v.lower() + # Load string into dictionary. try: v = json.loads(v) From fdc0124ee76f82aaf7b71bf091f35ee6e5d1f7f8 Mon Sep 17 00:00:00 2001 From: Jinping Han Date: Mon, 11 Feb 2019 12:05:25 -0800 Subject: [PATCH 2/2] Add one unit test case --- orquesta/tests/unit/utils/test_parameters.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/orquesta/tests/unit/utils/test_parameters.py b/orquesta/tests/unit/utils/test_parameters.py index 5ba96161..6d8a3cfd 100644 --- a/orquesta/tests/unit/utils/test_parameters.py +++ b/orquesta/tests/unit/utils/test_parameters.py @@ -83,6 +83,19 @@ def test_parse_empty_string(self): def test_parse_null_type(self): self.assertListEqual(params.parse_inline_params(None), []) + def test_parse_bool_input(self): + tests = [ + ('x=true', [{'x': True}]), + ('y=True', [{'y': True}]), + ('c=TRUE', [{'c': True}]), + ('x=false', [{'x': False}]), + ('y=False', [{'y': False}]), + ('c=FALSE', [{'c': False}]) + ] + + for s, d in tests: + self.assertListEqual(params.parse_inline_params(s), d) + def test_parse_other_types(self): self.assertListEqual(params.parse_inline_params(123), []) self.assertListEqual(params.parse_inline_params(True), [])