From de4ce26c200b4a6d70d12e7c498d9c704d0c3630 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sun, 10 Sep 2023 18:14:41 +0000 Subject: [PATCH] SFN: list_executions() now returns the StopDate-attribute (#6802) --- moto/stepfunctions/responses.py | 1 + .../test_stepfunctions/test_stepfunctions.py | 29 +++++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/moto/stepfunctions/responses.py b/moto/stepfunctions/responses.py index cf68b83bf..c6685aa19 100644 --- a/moto/stepfunctions/responses.py +++ b/moto/stepfunctions/responses.py @@ -141,6 +141,7 @@ class StepFunctionResponse(BaseResponse): "executionArn": execution.execution_arn, "name": execution.name, "startDate": execution.start_date, + "stopDate": execution.stop_date, "stateMachineArn": state_machine.arn, "status": execution.status, } diff --git a/tests/test_stepfunctions/test_stepfunctions.py b/tests/test_stepfunctions/test_stepfunctions.py index 02097ef9e..97f959714 100644 --- a/tests/test_stepfunctions/test_stepfunctions.py +++ b/tests/test_stepfunctions/test_stepfunctions.py @@ -758,15 +758,22 @@ def test_state_machine_throws_error_when_describing_unknown_execution(): def test_state_machine_stop_execution(): client = boto3.client("stepfunctions", region_name=region) # - sm = client.create_state_machine( + sm_arn = client.create_state_machine( name="name", definition=str(simple_definition), roleArn=_get_default_role() - ) - start = client.start_execution(stateMachineArn=sm["stateMachineArn"]) + )["stateMachineArn"] + start = client.start_execution(stateMachineArn=sm_arn) stop = client.stop_execution(executionArn=start["executionArn"]) # assert stop["ResponseMetadata"]["HTTPStatusCode"] == 200 assert isinstance(stop["stopDate"], datetime) + description = client.describe_execution(executionArn=start["executionArn"]) + assert description["status"] == "ABORTED" + assert isinstance(description["stopDate"], datetime) + + execution = client.list_executions(stateMachineArn=sm_arn)["executions"][0] + assert isinstance(execution["stopDate"], datetime) + @mock_stepfunctions @mock_sts @@ -786,22 +793,6 @@ def test_state_machine_stop_raises_error_when_unknown_execution(): assert "Execution Does Not Exist:" in ex.value.response["Error"]["Message"] -@mock_stepfunctions -@mock_sts -def test_state_machine_describe_execution_after_stoppage(): - client = boto3.client("stepfunctions", region_name=region) - sm = client.create_state_machine( - name="name", definition=str(simple_definition), roleArn=_get_default_role() - ) - execution = client.start_execution(stateMachineArn=sm["stateMachineArn"]) - client.stop_execution(executionArn=execution["executionArn"]) - description = client.describe_execution(executionArn=execution["executionArn"]) - # - assert description["ResponseMetadata"]["HTTPStatusCode"] == 200 - assert description["status"] == "ABORTED" - assert isinstance(description["stopDate"], datetime) - - @mock_stepfunctions @mock_sts def test_state_machine_get_execution_history_throws_error_with_unknown_execution():