@@ -1957,13 +1957,13 @@ def test_send_durable_execution_callback_success_handler():
19571957 assert isinstance (route , CallbackSuccessRoute )
19581958 assert route .callback_id == "test-callback-id"
19591959
1960- # Test with valid request body
1960+ # Test with valid request body (bytes for callback operations)
19611961 request = HTTPRequest (
19621962 method = "POST" ,
19631963 path = route ,
19641964 headers = {"Content-Type" : "application/json" },
19651965 query_params = {},
1966- body = { "CallbackId" : "test-callback-id" , "Result" : " success-result"} ,
1966+ body = b" success-result" ,
19671967 )
19681968
19691969 response = handler .handle (route , request )
@@ -1974,33 +1974,40 @@ def test_send_durable_execution_callback_success_handler():
19741974
19751975 # Verify executor was called with correct parameters
19761976 executor .send_callback_success .assert_called_once_with (
1977- callback_id = "test-callback-id" , result = "success-result"
1977+ callback_id = "test-callback-id" , result = b "success-result"
19781978 )
19791979
19801980
19811981def test_send_durable_execution_callback_success_handler_empty_body ():
19821982 """Test SendDurableExecutionCallbackSuccessHandler with empty body."""
19831983 executor = Mock ()
1984+ executor .send_callback_success .return_value = (
1985+ SendDurableExecutionCallbackSuccessResponse ()
1986+ )
19841987 handler = SendDurableExecutionCallbackSuccessHandler (executor )
19851988
1989+ base_route = Route .from_string (
1990+ "/2025-12-01/durable-execution-callbacks/test-id/succeed"
1991+ )
1992+ callback_route = CallbackSuccessRoute .from_route (base_route )
1993+
19861994 request = HTTPRequest (
19871995 method = "POST" ,
1988- path = Route .from_string (
1989- "/2025-12-01/durable-execution-callbacks/test-id/succeed"
1990- ),
1996+ path = callback_route ,
19911997 headers = {},
19921998 query_params = {},
1993- body = {} ,
1999+ body = b"" ,
19942000 )
19952001
1996- response = handler .handle (
1997- Route .from_string ("/2025-12-01/durable-execution-callbacks/test-id/succeed" ),
1998- request ,
2002+ response = handler .handle (callback_route , request )
2003+ # Handler should accept empty body (Result is optional) and return 200
2004+ assert response .status_code == 200
2005+ assert response .body == {}
2006+
2007+ # Verify executor was called with empty result
2008+ executor .send_callback_success .assert_called_once_with (
2009+ callback_id = "test-id" , result = b""
19992010 )
2000- # Handler returns 400 for empty body with AWS-compliant format
2001- assert response .status_code == 400
2002- assert response .body ["Type" ] == "InvalidParameterValueException"
2003- assert "Request body is required" in response .body ["message" ]
20042011
20052012
20062013def test_send_durable_execution_callback_failure_handler ():
@@ -2032,7 +2039,7 @@ def test_send_durable_execution_callback_failure_handler():
20322039 path = route ,
20332040 headers = {"Content-Type" : "application/json" },
20342041 query_params = {},
2035- body = { "CallbackId" : "test-callback-id" , "Error" : error_data },
2042+ body = error_data , # Pass error data directly as body
20362043 )
20372044 response = handler .handle (route , request )
20382045
@@ -2152,18 +2159,20 @@ def test_send_durable_execution_callback_failure_handler_empty_body():
21522159 executor = Mock ()
21532160 handler = SendDurableExecutionCallbackFailureHandler (executor )
21542161
2162+ base_route = Route .from_string (
2163+ "/2025-12-01/durable-execution-callbacks/test-id/fail"
2164+ )
2165+ callback_route = CallbackFailureRoute .from_route (base_route )
2166+
21552167 request = HTTPRequest (
21562168 method = "POST" ,
2157- path = Route . from_string ( "/2025-12-01/durable-execution-callbacks/test-id/fail" ) ,
2169+ path = callback_route ,
21582170 headers = {},
21592171 query_params = {},
21602172 body = {},
21612173 )
21622174
2163- response = handler .handle (
2164- Route .from_string ("/2025-12-01/durable-execution-callbacks/test-id/fail" ),
2165- request ,
2166- )
2175+ response = handler .handle (callback_route , request )
21672176 # Handler returns 400 for empty body with AWS-compliant format
21682177 assert response .status_code == 400
21692178 assert response .body ["Type" ] == "InvalidParameterValueException"
@@ -2533,7 +2542,7 @@ def test_callback_handlers_use_dataclass_serialization():
25332542 }
25342543
25352544 failure_request = SendDurableExecutionCallbackFailureRequest .from_dict (
2536- {"CallbackId" : "test-id" }
2545+ {}, "test-id"
25372546 )
25382547 assert failure_request .callback_id == "test-id"
25392548 assert failure_request .error is None
0 commit comments