Skip to content

Commit 97147ab

Browse files
Fix null value in ResultPath (#48)
* Fix null value in ResultPath Fixes #45 * Add unit test covering default ResultPath * Fix null values in InputPath and OutputPath
1 parent bb06bfb commit 97147ab

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

Diff for: src/stepfunctions/steps/states.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ def _replace_placeholders(self, params):
6666

6767
def to_dict(self):
6868
result = {}
69+
fields_accepted_as_none = ('result_path', 'input_path', 'output_path')
6970
# Common fields
7071
for k, v in self.fields.items():
71-
if v is not None:
72+
if v is not None or k in fields_accepted_as_none:
7273
k = to_pascalcase(k)
7374
if k == to_pascalcase(Field.Parameters.value):
7475
result[k] = self._replace_placeholders(v)

Diff for: tests/unit/test_steps.py

+40-1
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,43 @@ def test_retry_fail_for_unsupported_state():
346346
c1 = Choice('My Choice')
347347

348348
with pytest.raises(ValueError):
349-
c1.add_catch(Catch(error_equals=["States.NoChoiceMatched"], next_step=Fail("ChoiceFailed")))
349+
c1.add_catch(Catch(error_equals=["States.NoChoiceMatched"], next_step=Fail("ChoiceFailed")))
350+
351+
352+
def test_paths_none():
353+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda',
354+
result_path=None,
355+
input_path=None,
356+
output_path=None)
357+
assert 'ResultPath' in task_state.to_dict()
358+
assert task_state.to_dict()['ResultPath'] is None
359+
360+
assert 'InputPath' in task_state.to_dict()
361+
assert task_state.to_dict()['InputPath'] is None
362+
363+
assert 'OutputPath' in task_state.to_dict()
364+
assert task_state.to_dict()['OutputPath'] is None
365+
366+
367+
def test_paths_none_converted_to_null():
368+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda',
369+
result_path=None,
370+
input_path=None,
371+
output_path=None)
372+
assert '"ResultPath": null' in task_state.to_json()
373+
assert '"InputPath": null' in task_state.to_json()
374+
assert '"OutputPath": null' in task_state.to_json()
375+
376+
377+
def test_default_paths_not_included():
378+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda')
379+
assert 'ResultPath' not in task_state.to_dict()
380+
assert 'InputPath' not in task_state.to_dict()
381+
assert 'OutputPath' not in task_state.to_dict()
382+
383+
384+
def test_default_paths_not_converted_to_null():
385+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda')
386+
assert '"ResultPath": null' not in task_state.to_json()
387+
assert '"InputPath": null' not in task_state.to_json()
388+
assert '"OutputPath": null' not in task_state.to_json()

0 commit comments

Comments
 (0)