diff --git a/src/stepfunctions/steps/states.py b/src/stepfunctions/steps/states.py index 9b4e191..b6d81e1 100644 --- a/src/stepfunctions/steps/states.py +++ b/src/stepfunctions/steps/states.py @@ -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) diff --git a/tests/unit/test_steps.py b/tests/unit/test_steps.py index cc1fab0..1002238 100644 --- a/tests/unit/test_steps.py +++ b/tests/unit/test_steps.py @@ -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"))) \ No newline at end of file + 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()