diff --git a/src/aws_durable_execution_sdk_python_testing/executor.py b/src/aws_durable_execution_sdk_python_testing/executor.py index a27184e..08aa467 100644 --- a/src/aws_durable_execution_sdk_python_testing/executor.py +++ b/src/aws_durable_execution_sdk_python_testing/executor.py @@ -142,7 +142,7 @@ def get_execution_details(self, execution_arn: str) -> GetDurableExecutionRespon durable_execution_name=execution.start_input.execution_name, function_arn=f"arn:aws:lambda:us-east-1:123456789012:function:{execution.start_input.function_name}", status=status, - start_date=execution_op.start_timestamp.isoformat() + start_timestamp=execution_op.start_timestamp.isoformat() if execution_op.start_timestamp else datetime.now(UTC).isoformat(), input_payload=execution_op.execution_details.input_payload @@ -150,7 +150,7 @@ def get_execution_details(self, execution_arn: str) -> GetDurableExecutionRespon else None, result=result, error=error, - stop_date=execution_op.end_timestamp.isoformat() + end_timestamp=execution_op.end_timestamp.isoformat() if execution_op.end_timestamp else None, version="1.0", @@ -223,17 +223,17 @@ def list_executions( durable_execution_name=execution.start_input.execution_name, function_arn=f"arn:aws:lambda:us-east-1:123456789012:function:{execution.start_input.function_name}", status=execution_status, - start_date=execution_op.start_timestamp.isoformat() + start_timestamp=execution_op.start_timestamp.isoformat() if execution_op.start_timestamp else datetime.now(UTC).isoformat(), - stop_date=execution_op.end_timestamp.isoformat() + end_timestamp=execution_op.end_timestamp.isoformat() if execution_op.end_timestamp else None, ) filtered_executions.append(execution_summary) # Sort by start date - filtered_executions.sort(key=lambda e: e.start_date, reverse=reverse_order) + filtered_executions.sort(key=lambda e: e.start_timestamp, reverse=reverse_order) # Apply pagination if max_items is None: diff --git a/src/aws_durable_execution_sdk_python_testing/model.py b/src/aws_durable_execution_sdk_python_testing/model.py index 0d406cb..8753c8a 100644 --- a/src/aws_durable_execution_sdk_python_testing/model.py +++ b/src/aws_durable_execution_sdk_python_testing/model.py @@ -131,11 +131,11 @@ class GetDurableExecutionResponse: durable_execution_name: str function_arn: str status: str - start_date: str + start_timestamp: str input_payload: str | None = None result: str | None = None error: ErrorObject | None = None - stop_date: str | None = None + end_timestamp: str | None = None version: str | None = None @classmethod @@ -149,11 +149,11 @@ def from_dict(cls, data: dict) -> GetDurableExecutionResponse: durable_execution_name=data["DurableExecutionName"], function_arn=data["FunctionArn"], status=data["Status"], - start_date=data["StartDate"], + start_timestamp=data["StartTimestamp"], input_payload=data.get("InputPayload"), result=data.get("Result"), error=error, - stop_date=data.get("StopDate"), + end_timestamp=data.get("EndTimestamp"), version=data.get("Version"), ) @@ -163,7 +163,7 @@ def to_dict(self) -> dict[str, Any]: "DurableExecutionName": self.durable_execution_name, "FunctionArn": self.function_arn, "Status": self.status, - "StartDate": self.start_date, + "StartTimestamp": self.start_timestamp, } if self.input_payload is not None: result["InputPayload"] = self.input_payload @@ -171,8 +171,10 @@ def to_dict(self) -> dict[str, Any]: result["Result"] = self.result if self.error is not None: result["Error"] = self.error.to_dict() - if self.stop_date is not None: - result["StopDate"] = self.stop_date + if self.end_timestamp is not None: + result["EndTimestamp"] = self.end_timestamp + if self.end_timestamp is not None: + result["EndTimestamp"] = self.end_timestamp if self.version is not None: result["Version"] = self.version return result @@ -186,8 +188,8 @@ class Execution: durable_execution_name: str function_arn: str status: str - start_date: str - stop_date: str | None = None + start_timestamp: str + end_timestamp: str | None = None @classmethod def from_dict(cls, data: dict) -> Execution: @@ -198,8 +200,8 @@ def from_dict(cls, data: dict) -> Execution: "FunctionArn", "" ), # Make optional for backward compatibility status=data["Status"], - start_date=data["StartDate"], - stop_date=data.get("StopDate"), + start_timestamp=data["StartTimestamp"], + end_timestamp=data.get("EndTimestamp"), ) def to_dict(self) -> dict[str, Any]: @@ -207,12 +209,12 @@ def to_dict(self) -> dict[str, Any]: "DurableExecutionArn": self.durable_execution_arn, "DurableExecutionName": self.durable_execution_name, "Status": self.status, - "StartDate": self.start_date, + "StartTimestamp": self.start_timestamp, } if self.function_arn: # Only include if not empty result["FunctionArn"] = self.function_arn - if self.stop_date is not None: - result["StopDate"] = self.stop_date + if self.end_timestamp is not None: + result["EndTimestamp"] = self.end_timestamp return result diff --git a/tests/model_test.py b/tests/model_test.py index 02c0249..94d8b92 100644 --- a/tests/model_test.py +++ b/tests/model_test.py @@ -180,11 +180,11 @@ def test_get_durable_execution_response_serialization(): "DurableExecutionName": "test-execution", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", "InputPayload": "test-input", "Result": "test-result", "Error": {"ErrorMessage": "test error"}, - "StopDate": "2023-01-01T00:01:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", "Version": "1.0", } @@ -199,11 +199,11 @@ def test_get_durable_execution_response_serialization(): == "arn:aws:lambda:us-east-1:123456789012:function:my-function" ) assert response_obj.status == "SUCCEEDED" - assert response_obj.start_date == "2023-01-01T00:00:00Z" + assert response_obj.start_timestamp == "2023-01-01T00:00:00Z" assert response_obj.input_payload == "test-input" assert response_obj.result == "test-result" assert response_obj.error.message == "test error" - assert response_obj.stop_date == "2023-01-01T00:01:00Z" + assert response_obj.end_timestamp == "2023-01-01T00:01:00Z" assert response_obj.version == "1.0" result_data = response_obj.to_dict() @@ -221,14 +221,14 @@ def test_get_durable_execution_response_minimal(): "DurableExecutionName": "test-execution", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function", "Status": "RUNNING", - "StartDate": "2023-01-01T00:00:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", } response_obj = GetDurableExecutionResponse.from_dict(data) assert response_obj.input_payload is None assert response_obj.result is None assert response_obj.error is None - assert response_obj.stop_date is None + assert response_obj.end_timestamp is None assert response_obj.version is None result_data = response_obj.to_dict() @@ -295,8 +295,8 @@ def test_durable_execution_summary_serialization(): "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test", "DurableExecutionName": "test-execution", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", } summary_obj = Execution.from_dict(data) @@ -306,8 +306,8 @@ def test_durable_execution_summary_serialization(): ) assert summary_obj.durable_execution_name == "test-execution" assert summary_obj.status == "SUCCEEDED" - assert summary_obj.start_date == "2023-01-01T00:00:00Z" - assert summary_obj.stop_date == "2023-01-01T00:01:00Z" + assert summary_obj.start_timestamp == "2023-01-01T00:00:00Z" + assert summary_obj.end_timestamp == "2023-01-01T00:01:00Z" result_data = summary_obj.to_dict() assert result_data == data @@ -323,11 +323,11 @@ def test_durable_execution_summary_no_stop_date(): "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test", "DurableExecutionName": "test-execution", "Status": "RUNNING", - "StartDate": "2023-01-01T00:00:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", } summary_obj = Execution.from_dict(data) - assert summary_obj.stop_date is None + assert summary_obj.end_timestamp is None result_data = summary_obj.to_dict() assert result_data == data @@ -341,14 +341,14 @@ def test_list_durable_executions_response_serialization(): "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test1", "DurableExecutionName": "test-execution-1", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", }, { "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test2", "DurableExecutionName": "test-execution-2", "Status": "RUNNING", - "StartDate": "2023-01-01T00:02:00Z", + "StartTimestamp": "2023-01-01T00:02:00Z", }, ], "NextMarker": "next-marker-123", @@ -738,8 +738,8 @@ def test_list_durable_executions_by_function_response_serialization(): "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test1", "DurableExecutionName": "test-execution-1", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", } ], "NextMarker": "next-marker-123", @@ -1183,8 +1183,8 @@ def test_execution_backward_compatibility_empty_function_arn(): "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test", "DurableExecutionName": "test-execution", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", } execution_obj = Execution.from_dict(data) @@ -1198,8 +1198,8 @@ def test_execution_backward_compatibility_empty_function_arn(): "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test", "DurableExecutionName": "test-execution", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", } assert result_data == expected_data @@ -1211,8 +1211,8 @@ def test_execution_with_function_arn(): "DurableExecutionName": "test-execution", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", } execution_obj = Execution.from_dict(data) diff --git a/tests/web/handlers_test.py b/tests/web/handlers_test.py index 8f224a7..2045a96 100644 --- a/tests/web/handlers_test.py +++ b/tests/web/handlers_test.py @@ -599,11 +599,11 @@ def test_get_durable_execution_handler_success(): durable_execution_name="test-execution", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="SUCCEEDED", - start_date="2023-01-01T00:00:00Z", + start_timestamp="2023-01-01T00:00:00Z", input_payload="test-input", result="test-result", error=None, - stop_date="2023-01-01T00:01:00Z", + end_timestamp="2023-01-01T00:01:00Z", version="1.0", ) executor.get_execution_details.return_value = mock_response @@ -629,10 +629,10 @@ def test_get_durable_execution_handler_success(): "DurableExecutionName": "test-execution", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", "InputPayload": "test-input", "Result": "test-result", - "StopDate": "2023-01-01T00:01:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", "Version": "1.0", } assert response.body == expected_body @@ -1235,16 +1235,16 @@ def test_list_durable_executions_handler_success(): durable_execution_name="test-execution-1", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="SUCCEEDED", - start_date="2023-01-01T00:00:00Z", - stop_date="2023-01-01T00:01:00Z", + start_timestamp="2023-01-01T00:00:00Z", + end_timestamp="2023-01-01T00:01:00Z", ), ExecutionSummary( durable_execution_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function:execution:test-2", durable_execution_name="test-execution-2", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="RUNNING", - start_date="2023-01-01T00:02:00Z", - stop_date=None, + start_timestamp="2023-01-01T00:02:00Z", + end_timestamp=None, ), ] @@ -1277,15 +1277,15 @@ def test_list_durable_executions_handler_success(): "DurableExecutionName": "test-execution-1", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", }, { "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function:execution:test-2", "DurableExecutionName": "test-execution-2", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function", "Status": "RUNNING", - "StartDate": "2023-01-01T00:02:00Z", + "StartTimestamp": "2023-01-01T00:02:00Z", }, ] } @@ -1317,8 +1317,8 @@ def test_list_durable_executions_handler_with_filters(): durable_execution_name="filtered-execution", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="SUCCEEDED", - start_date="2023-01-01T00:00:00Z", - stop_date="2023-01-01T00:01:00Z", + start_timestamp="2023-01-01T00:00:00Z", + end_timestamp="2023-01-01T00:01:00Z", ), ] @@ -1362,8 +1362,8 @@ def test_list_durable_executions_handler_with_filters(): "DurableExecutionName": "filtered-execution", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", }, ], "NextMarker": "next-page-token", @@ -1396,8 +1396,8 @@ def test_list_durable_executions_handler_pagination(): durable_execution_name=f"page-execution-{i}", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="SUCCEEDED", - start_date=f"2023-01-0{i}T00:00:00Z", - stop_date=f"2023-01-0{i}T00:01:00Z", + start_timestamp=f"2023-01-0{i}T00:00:00Z", + end_timestamp=f"2023-01-0{i}T00:01:00Z", ) for i in range(1, 4) # 3 executions ] @@ -1492,8 +1492,8 @@ def test_list_durable_executions_handler_dataclass_serialization(): durable_execution_name="test-execution", function_arn="test-function-arn", status="SUCCEEDED", - start_date="2023-01-01T00:00:00Z", - stop_date="2023-01-01T00:01:00Z", + start_timestamp="2023-01-01T00:00:00Z", + end_timestamp="2023-01-01T00:01:00Z", ), ] @@ -1652,16 +1652,16 @@ def test_list_durable_executions_by_function_handler_success(): durable_execution_name="function-execution-1", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="SUCCEEDED", - start_date="2023-01-01T00:00:00Z", - stop_date="2023-01-01T00:01:00Z", + start_timestamp="2023-01-01T00:00:00Z", + end_timestamp="2023-01-01T00:01:00Z", ), ExecutionSummary( durable_execution_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function:execution:func-2", durable_execution_name="function-execution-2", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="RUNNING", - start_date="2023-01-01T00:02:00Z", - stop_date=None, + start_timestamp="2023-01-01T00:02:00Z", + end_timestamp=None, ), ] @@ -1696,15 +1696,15 @@ def test_list_durable_executions_by_function_handler_success(): "DurableExecutionName": "function-execution-1", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", }, { "DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function:execution:func-2", "DurableExecutionName": "function-execution-2", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function", "Status": "RUNNING", - "StartDate": "2023-01-01T00:02:00Z", + "StartTimestamp": "2023-01-01T00:02:00Z", }, ] } @@ -1737,8 +1737,8 @@ def test_list_durable_executions_by_function_handler_with_filters(): durable_execution_name="filtered-execution", function_arn="arn:aws:lambda:us-east-1:123456789012:function:test-function", status="SUCCEEDED", - start_date="2023-01-01T00:00:00Z", - stop_date="2023-01-01T00:01:00Z", + start_timestamp="2023-01-01T00:00:00Z", + end_timestamp="2023-01-01T00:01:00Z", ), ] @@ -1783,8 +1783,8 @@ def test_list_durable_executions_by_function_handler_with_filters(): "DurableExecutionName": "filtered-execution", "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:test-function", "Status": "SUCCEEDED", - "StartDate": "2023-01-01T00:00:00Z", - "StopDate": "2023-01-01T00:01:00Z", + "StartTimestamp": "2023-01-01T00:00:00Z", + "EndTimestamp": "2023-01-01T00:01:00Z", }, ], "NextMarker": "next-page-token", @@ -1818,8 +1818,8 @@ def test_list_durable_executions_by_function_handler_dataclass_serialization(): durable_execution_name="test-execution", function_arn="test-function-arn", status="SUCCEEDED", - start_date="2023-01-01T00:00:00Z", - stop_date="2023-01-01T00:01:00Z", + start_timestamp="2023-01-01T00:00:00Z", + end_timestamp="2023-01-01T00:01:00Z", ), ]