Skip to content
Merged
3 changes: 2 additions & 1 deletion packs/asserts/actions/object_key_number_equals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ def run(self, object, key, value):
if key not in object:
sys.stderr.write('KEY %s DOESN\'T EXIST.' % key)
raise ValueError('Key %s doesn\'t exist in object %s' % (key, object))
result = (object[key] == value)
result = (int(object[key]) == int(value))
if result:
sys.stdout.write('EQUAL.')
else:
sys.stdout.write('NOT EQUAL.')
sys.stderr.write(' Expected: %s, Original: %s' % (value, object[key]))
raise ValueError('Value not equal. Expected "%s", got "%s". ' % (value, object[key]))
return result
5 changes: 3 additions & 2 deletions packs/asserts/actions/object_key_number_greater.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def run(self, object, key, value):
raise ValueError('Key %s doesn\'t exist in object %s' % (key, object))
result = (object[key] > value)
if result:
sys.stdout.write('GREATER')
sys.stdout.write('GREATER (%s > %s)' % (object[key], value))
else:
sys.stdout.write('LESSER')
sys.stdout.write('LESSER (%s < %s)' % (object[key], value))
raise ValueError('"%s" is not greater than "%s"' % (object[key], value))
return result
1 change: 1 addition & 0 deletions packs/asserts/actions/object_key_string_equals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ def run(self, object, key, value):
sys.stdout.write('EQUAL')
else:
sys.stdout.write('NOT EQUAL')
raise ValueError('Value not equal. Expected "%s", got "%s". ' % (value, object[key]))
return result
9 changes: 8 additions & 1 deletion packs/fixtures/actions/scripts/streamwriter-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import sys
import ast
import re

from lib.exceptions import CustomException

Expand All @@ -25,15 +26,21 @@ def main(args):
stream = args.stream
writer = StreamWriter()
stream = writer.run(stream)

str_arg = args.str_arg
int_arg = args.int_arg
obj_arg = args.obj_arg

if str_arg:
sys.stdout.write(' STR: %s' % str_arg)
if int_arg:
sys.stdout.write(' INT: %d' % int_arg)

if obj_arg:
sys.stdout.write(' OBJ: %s' % obj_arg)
# Remove any u'' so it works consistently under Python 2 and 3.x
obj_arg_str = str(obj_arg)
value = re.sub("u'(.*?)'", r"'\1'", obj_arg_str)
sys.stdout.write(' OBJ: %s' % value)


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ chain:
params:
object: "{{test_stdout_local_script_action}}"
key: "stdout"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {u'foo': u'bar baz'}"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {'foo': 'bar baz'}"
on-success: "assert_return_code_zero_stdout_test"
-
name: "assert_return_code_zero_stdout_test"
Expand Down Expand Up @@ -79,4 +79,4 @@ chain:
params:
object: "{{test_stdout_local_script_action_sudo}}"
key: "stdout"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {u'foo': u'bar baz'}"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {'foo': 'bar baz'}"
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ chain:
params:
object: "{{test_stdout_remote_script_action.localhost}}"
key: "stdout"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {u'foo': u'bar baz'}"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {'foo': 'bar baz'}"
on-success: "assert_return_code_zero_stdout_test"
-
name: "assert_return_code_zero_stdout_test"
Expand Down Expand Up @@ -83,4 +83,4 @@ chain:
params:
object: "{{test_stdout_remote_script_action_sudo.localhost}}"
key: "stdout"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {u'foo': u'bar baz'}"
value: "STREAM IS STDOUT. STR: foo bar\nbaz INT: 1 OBJ: {'foo': 'bar baz'}"
2 changes: 1 addition & 1 deletion packs/tests/actions/chains/test_quickstart_trace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: "st2 trace get {{get_trace_id_for_tag.stdout | replace('\n', '')}} -j | grep execution | wc -l"
cmd: "st2 trace get {{get_trace_id_for_tag.stdout | replace('\n', '')}} -j | grep action_execution | grep type | wc -l"
on-success: "assert_trace_id_has_two_executions"
-
name: "assert_trace_id_has_two_executions"
Expand Down