Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/aws_durable_execution_sdk_python_testing/web/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,24 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
history_route = cast(GetDurableExecutionHistoryRoute, parsed_route)
execution_arn: str = history_route.arn

max_results: str | None = self._parse_query_param(request, "maxResults")
next_token: str | None = self._parse_query_param(request, "nextToken")
max_items: str | None = self._parse_query_param(request, "MaxItems")
marker: str | None = self._parse_query_param(request, "Marker")
include_execution_data_str: str | None = self._parse_query_param(
request, "IncludeExecutionData"
)
include_execution_data: bool = (
include_execution_data_str == "true"
if include_execution_data_str
else False
)

history_response: GetDurableExecutionHistoryResponse = (
self.executor.get_execution_history(
execution_arn,
include_execution_data=False,
include_execution_data=include_execution_data,
reverse_order=False,
marker=next_token,
max_items=int(max_results) if max_results else None,
marker=marker,
max_items=int(max_items) if max_items else None,
)
)

Expand Down
84 changes: 82 additions & 2 deletions tests/web/handlers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ def test_get_durable_execution_history_handler_success():
method="GET",
path=typed_route,
headers={},
query_params={"maxResults": ["10"], "nextToken": ["token-123"]},
query_params={"MaxItems": ["10"], "Marker": ["token-123"]},
body={},
)

Expand Down Expand Up @@ -1203,7 +1203,7 @@ def test_get_durable_execution_history_handler_with_query_params():
method="GET",
path=typed_route,
headers={},
query_params={"maxResults": ["25"]},
query_params={"MaxItems": ["25"]},
body={},
)

Expand All @@ -1223,6 +1223,86 @@ def test_get_durable_execution_history_handler_with_query_params():
)


def test_get_durable_execution_history_handler_with_include_execution_data():
"""Test GetDurableExecutionHistoryHandler with IncludeExecutionData parameter."""

executor = Mock()
handler = GetDurableExecutionHistoryHandler(executor)

# Mock the executor response
mock_response = GetDurableExecutionHistoryResponse(events=[], next_marker=None)
executor.get_execution_history.return_value = mock_response

# Create strongly-typed route using Router
router = Router()
typed_route = router.find_route(
"/2025-12-01/durable-executions/test-arn/history", "GET"
)

request = HTTPRequest(
method="GET",
path=typed_route,
headers={},
query_params={"IncludeExecutionData": ["true"], "MaxItems": ["1000"]},
body={},
)

response = handler.handle(typed_route, request)

# Verify response
assert response.status_code == 200
assert response.body == {"Events": []}

# Verify executor was called with include_execution_data=True
executor.get_execution_history.assert_called_once_with(
"test-arn",
include_execution_data=True,
reverse_order=False,
marker=None,
max_items=1000,
)


def test_get_durable_execution_history_handler_with_include_execution_data_false():
"""Test GetDurableExecutionHistoryHandler with IncludeExecutionData=false."""

executor = Mock()
handler = GetDurableExecutionHistoryHandler(executor)

# Mock the executor response
mock_response = GetDurableExecutionHistoryResponse(events=[], next_marker=None)
executor.get_execution_history.return_value = mock_response

# Create strongly-typed route using Router
router = Router()
typed_route = router.find_route(
"/2025-12-01/durable-executions/test-arn/history", "GET"
)

request = HTTPRequest(
method="GET",
path=typed_route,
headers={},
query_params={"IncludeExecutionData": ["false"]},
body={},
)

response = handler.handle(typed_route, request)

# Verify response
assert response.status_code == 200
assert response.body == {"Events": []}

# Verify executor was called with include_execution_data=False
executor.get_execution_history.assert_called_once_with(
"test-arn",
include_execution_data=False,
reverse_order=False,
marker=None,
max_items=None,
)


def test_list_durable_executions_handler_success():
"""Test ListDurableExecutionsHandler with successful execution listing."""
executor = Mock()
Expand Down
Loading