Skip to content

Commit

Permalink
Merge pull request #129 from StackStorm/issue_124
Browse files Browse the repository at this point in the history
Failure to publish `True` to a variable using `shorthand format
  • Loading branch information
jinpingh authored Feb 13, 2019
2 parents 774123b + 8eb160c commit c77f1e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions orquesta/tests/unit/utils/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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), [])
Expand Down
7 changes: 5 additions & 2 deletions orquesta/utils/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c77f1e6

Please sign in to comment.