@@ -2048,6 +2048,104 @@ def test_send_durable_execution_callback_failure_handler():
20482048 assert call_args [1 ]["error" ].message == "Test error"
20492049
20502050
2051+ def test_update_lambda_endpoint_handler_success ():
2052+ """Test UpdateLambdaEndpointHandler with valid request."""
2053+ from aws_durable_execution_sdk_python_testing .invoker import LambdaInvoker
2054+ from aws_durable_execution_sdk_python_testing .web .handlers import (
2055+ UpdateLambdaEndpointHandler ,
2056+ )
2057+ from aws_durable_execution_sdk_python_testing .web .routes import (
2058+ UpdateLambdaEndpointRoute ,
2059+ )
2060+
2061+ executor = Mock ()
2062+ lambda_invoker = Mock (spec = LambdaInvoker )
2063+ executor ._invoker = lambda_invoker # noqa: SLF001
2064+ handler = UpdateLambdaEndpointHandler (executor )
2065+
2066+ base_route = Route .from_string ("/lambda-endpoint" )
2067+ update_route = UpdateLambdaEndpointRoute .from_route (base_route )
2068+
2069+ request = HTTPRequest (
2070+ method = "PUT" ,
2071+ path = update_route ,
2072+ headers = {"Content-Type" : "application/json" },
2073+ query_params = {},
2074+ body = {"EndpointUrl" : "http://localhost:8080" , "RegionName" : "us-west-2" },
2075+ )
2076+
2077+ response = handler .handle (update_route , request )
2078+
2079+ assert response .status_code == 200
2080+ assert response .body == {"message" : "Lambda endpoint updated successfully" }
2081+ lambda_invoker .update_endpoint .assert_called_once_with (
2082+ "http://localhost:8080" , "us-west-2"
2083+ )
2084+
2085+
2086+ def test_update_lambda_endpoint_handler_missing_endpoint_url ():
2087+ """Test UpdateLambdaEndpointHandler with missing EndpointUrl."""
2088+ from aws_durable_execution_sdk_python_testing .web .handlers import (
2089+ UpdateLambdaEndpointHandler ,
2090+ )
2091+ from aws_durable_execution_sdk_python_testing .web .routes import (
2092+ UpdateLambdaEndpointRoute ,
2093+ )
2094+
2095+ executor = Mock ()
2096+ handler = UpdateLambdaEndpointHandler (executor )
2097+
2098+ base_route = Route .from_string ("/lambda-endpoint" )
2099+ update_route = UpdateLambdaEndpointRoute .from_route (base_route )
2100+
2101+ request = HTTPRequest (
2102+ method = "PUT" ,
2103+ path = update_route ,
2104+ headers = {"Content-Type" : "application/json" },
2105+ query_params = {},
2106+ body = {"RegionName" : "us-west-2" },
2107+ )
2108+
2109+ response = handler .handle (update_route , request )
2110+
2111+ assert response .status_code == 400
2112+ assert response .body == {"error" : "EndpointUrl is required" }
2113+
2114+
2115+ def test_update_lambda_endpoint_handler_default_region ():
2116+ """Test UpdateLambdaEndpointHandler uses default region when not specified."""
2117+ from aws_durable_execution_sdk_python_testing .invoker import LambdaInvoker
2118+ from aws_durable_execution_sdk_python_testing .web .handlers import (
2119+ UpdateLambdaEndpointHandler ,
2120+ )
2121+ from aws_durable_execution_sdk_python_testing .web .routes import (
2122+ UpdateLambdaEndpointRoute ,
2123+ )
2124+
2125+ executor = Mock ()
2126+ lambda_invoker = Mock (spec = LambdaInvoker )
2127+ executor ._invoker = lambda_invoker # noqa: SLF001
2128+ handler = UpdateLambdaEndpointHandler (executor )
2129+
2130+ base_route = Route .from_string ("/lambda-endpoint" )
2131+ update_route = UpdateLambdaEndpointRoute .from_route (base_route )
2132+
2133+ request = HTTPRequest (
2134+ method = "PUT" ,
2135+ path = update_route ,
2136+ headers = {"Content-Type" : "application/json" },
2137+ query_params = {},
2138+ body = {"EndpointUrl" : "http://localhost:8080" },
2139+ )
2140+
2141+ response = handler .handle (update_route , request )
2142+
2143+ assert response .status_code == 200
2144+ lambda_invoker .update_endpoint .assert_called_once_with (
2145+ "http://localhost:8080" , "us-east-1"
2146+ )
2147+
2148+
20512149def test_send_durable_execution_callback_failure_handler_empty_body ():
20522150 """Test SendDurableExecutionCallbackFailureHandler with empty body."""
20532151 executor = Mock ()
0 commit comments