-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_map_operations_flat.py
More file actions
39 lines (30 loc) · 1.35 KB
/
test_map_operations_flat.py
File metadata and controls
39 lines (30 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Tests for map_operations example."""
import pytest
from aws_durable_execution_sdk_python.execution import InvocationStatus
from aws_durable_execution_sdk_python.lambda_service import OperationStatus
from src.map import map_operations_flat
from test.conftest import deserialize_operation_payload
@pytest.mark.example
@pytest.mark.durable_execution(
handler=map_operations_flat.handler,
lambda_function_name="map operations",
)
def test_map_operations(durable_runner):
"""Test map_operations example using context.map()."""
with durable_runner:
result = durable_runner.run(input="test", timeout=10)
assert result.status is InvocationStatus.SUCCEEDED
assert deserialize_operation_payload(result.result) == [2, 4, 6, 8, 10]
# Get the map operation (CONTEXT type with MAP subtype)
map_op = result.get_context("map_operation")
assert map_op is not None
assert map_op.status is OperationStatus.SUCCEEDED
# Verify all five child operations exist
assert len(map_op.child_operations) == 5
# Verify child step operation names
child_names = {op.name for op in map_op.child_operations}
expected_names = {f"map_item_{i}" for i in range(5)}
assert child_names == expected_names
# Verify all children succeeded
for child in map_op.child_operations:
assert child.status is OperationStatus.SUCCEEDED