|
10 | 10 | ChainedInvokeDetails, |
11 | 11 | CheckpointOutput, |
12 | 12 | CheckpointUpdatedExecutionState, |
| 13 | + ContextDetails, |
13 | 14 | ErrorObject, |
14 | 15 | LambdaClient, |
15 | 16 | Operation, |
@@ -123,6 +124,74 @@ def test_checkpointed_result_create_from_operation_invoke_with_both_result_and_e |
123 | 124 | assert result.error == error |
124 | 125 |
|
125 | 126 |
|
| 127 | +def test_checkpointed_result_create_from_operation_context(): |
| 128 | + """Test CheckpointedResult.create_from_operation with CONTEXT operation.""" |
| 129 | + context_details = ContextDetails(result="context_result") |
| 130 | + operation = Operation( |
| 131 | + operation_id="op1", |
| 132 | + operation_type=OperationType.CONTEXT, |
| 133 | + status=OperationStatus.SUCCEEDED, |
| 134 | + context_details=context_details, |
| 135 | + ) |
| 136 | + result = CheckpointedResult.create_from_operation(operation) |
| 137 | + assert result.operation == operation |
| 138 | + assert result.status == OperationStatus.SUCCEEDED |
| 139 | + assert result.result == "context_result" |
| 140 | + assert result.error is None |
| 141 | + |
| 142 | + |
| 143 | +def test_checkpointed_result_create_from_operation_context_with_error(): |
| 144 | + """Test CheckpointedResult.create_from_operation with CONTEXT operation and error.""" |
| 145 | + error = ErrorObject( |
| 146 | + message="Context error", type="ContextError", data=None, stack_trace=None |
| 147 | + ) |
| 148 | + context_details = ContextDetails(error=error) |
| 149 | + operation = Operation( |
| 150 | + operation_id="op1", |
| 151 | + operation_type=OperationType.CONTEXT, |
| 152 | + status=OperationStatus.FAILED, |
| 153 | + context_details=context_details, |
| 154 | + ) |
| 155 | + result = CheckpointedResult.create_from_operation(operation) |
| 156 | + assert result.operation == operation |
| 157 | + assert result.status == OperationStatus.FAILED |
| 158 | + assert result.result is None |
| 159 | + assert result.error == error |
| 160 | + |
| 161 | + |
| 162 | +def test_checkpointed_result_create_from_operation_context_no_details(): |
| 163 | + """Test CheckpointedResult.create_from_operation with CONTEXT operation but no context_details.""" |
| 164 | + operation = Operation( |
| 165 | + operation_id="op1", |
| 166 | + operation_type=OperationType.CONTEXT, |
| 167 | + status=OperationStatus.STARTED, |
| 168 | + ) |
| 169 | + result = CheckpointedResult.create_from_operation(operation) |
| 170 | + assert result.operation == operation |
| 171 | + assert result.status == OperationStatus.STARTED |
| 172 | + assert result.result is None |
| 173 | + assert result.error is None |
| 174 | + |
| 175 | + |
| 176 | +def test_checkpointed_result_create_from_operation_context_with_both_result_and_error(): |
| 177 | + """Test CheckpointedResult.create_from_operation with CONTEXT operation having both result and error.""" |
| 178 | + error = ErrorObject( |
| 179 | + message="Context error", type="ContextError", data=None, stack_trace=None |
| 180 | + ) |
| 181 | + context_details = ContextDetails(result="context_result", error=error) |
| 182 | + operation = Operation( |
| 183 | + operation_id="op1", |
| 184 | + operation_type=OperationType.CONTEXT, |
| 185 | + status=OperationStatus.FAILED, |
| 186 | + context_details=context_details, |
| 187 | + ) |
| 188 | + result = CheckpointedResult.create_from_operation(operation) |
| 189 | + assert result.operation == operation |
| 190 | + assert result.status == OperationStatus.FAILED |
| 191 | + assert result.result == "context_result" |
| 192 | + assert result.error == error |
| 193 | + |
| 194 | + |
126 | 195 | def test_checkpointed_result_create_from_operation_unknown_type(): |
127 | 196 | """Test CheckpointedResult.create_from_operation with unknown operation type.""" |
128 | 197 | # Create operation with a mock operation type that doesn't match any case |
|
0 commit comments