Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/stepfunctions/steps/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def _replace_placeholders(self, params):

def to_dict(self):
result = {}
fields_accepted_as_none = ('result_path', 'input_path', 'output_path')
# Common fields
for k, v in self.fields.items():
if v is not None:
if v is not None or k in fields_accepted_as_none:
k = to_pascalcase(k)
if k == to_pascalcase(Field.Parameters.value):
result[k] = self._replace_placeholders(v)
Expand Down
41 changes: 40 additions & 1 deletion tests/unit/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,43 @@ def test_retry_fail_for_unsupported_state():
c1 = Choice('My Choice')

with pytest.raises(ValueError):
c1.add_catch(Catch(error_equals=["States.NoChoiceMatched"], next_step=Fail("ChoiceFailed")))
c1.add_catch(Catch(error_equals=["States.NoChoiceMatched"], next_step=Fail("ChoiceFailed")))


def test_paths_none():
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda',
result_path=None,
input_path=None,
output_path=None)
assert 'ResultPath' in task_state.to_dict()
assert task_state.to_dict()['ResultPath'] is None

assert 'InputPath' in task_state.to_dict()
assert task_state.to_dict()['InputPath'] is None

assert 'OutputPath' in task_state.to_dict()
assert task_state.to_dict()['OutputPath'] is None


def test_paths_none_converted_to_null():
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda',
result_path=None,
input_path=None,
output_path=None)
assert '"ResultPath": null' in task_state.to_json()
assert '"InputPath": null' in task_state.to_json()
assert '"OutputPath": null' in task_state.to_json()


def test_default_paths_not_included():
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda')
assert 'ResultPath' not in task_state.to_dict()
assert 'InputPath' not in task_state.to_dict()
assert 'OutputPath' not in task_state.to_dict()


def test_default_paths_not_converted_to_null():
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda')
assert '"ResultPath": null' not in task_state.to_json()
assert '"InputPath": null' not in task_state.to_json()
assert '"OutputPath": null' not in task_state.to_json()