@@ -2048,6 +2048,134 @@ 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_not_lambda_invoker ():
2116+ """Test UpdateLambdaEndpointHandler when not using LambdaInvoker."""
2117+ from aws_durable_execution_sdk_python_testing .web .handlers import (
2118+ UpdateLambdaEndpointHandler ,
2119+ )
2120+ from aws_durable_execution_sdk_python_testing .web .routes import (
2121+ UpdateLambdaEndpointRoute ,
2122+ )
2123+
2124+ executor = Mock ()
2125+ executor ._invoker = Mock () # Not a LambdaInvoker # noqa: SLF001
2126+ handler = UpdateLambdaEndpointHandler (executor )
2127+
2128+ base_route = Route .from_string ("/lambda-endpoint" )
2129+ update_route = UpdateLambdaEndpointRoute .from_route (base_route )
2130+
2131+ request = HTTPRequest (
2132+ method = "PUT" ,
2133+ path = update_route ,
2134+ headers = {"Content-Type" : "application/json" },
2135+ query_params = {},
2136+ body = {"EndpointUrl" : "http://localhost:8080" },
2137+ )
2138+
2139+ response = handler .handle (update_route , request )
2140+
2141+ assert response .status_code == 400
2142+ assert response .body == {"error" : "Not using LambdaInvoker" }
2143+
2144+
2145+ def test_update_lambda_endpoint_handler_default_region ():
2146+ """Test UpdateLambdaEndpointHandler uses default region when not specified."""
2147+ from aws_durable_execution_sdk_python_testing .invoker import LambdaInvoker
2148+ from aws_durable_execution_sdk_python_testing .web .handlers import (
2149+ UpdateLambdaEndpointHandler ,
2150+ )
2151+ from aws_durable_execution_sdk_python_testing .web .routes import (
2152+ UpdateLambdaEndpointRoute ,
2153+ )
2154+
2155+ executor = Mock ()
2156+ lambda_invoker = Mock (spec = LambdaInvoker )
2157+ executor ._invoker = lambda_invoker # noqa: SLF001
2158+ handler = UpdateLambdaEndpointHandler (executor )
2159+
2160+ base_route = Route .from_string ("/lambda-endpoint" )
2161+ update_route = UpdateLambdaEndpointRoute .from_route (base_route )
2162+
2163+ request = HTTPRequest (
2164+ method = "PUT" ,
2165+ path = update_route ,
2166+ headers = {"Content-Type" : "application/json" },
2167+ query_params = {},
2168+ body = {"EndpointUrl" : "http://localhost:8080" },
2169+ )
2170+
2171+ response = handler .handle (update_route , request )
2172+
2173+ assert response .status_code == 200
2174+ lambda_invoker .update_endpoint .assert_called_once_with (
2175+ "http://localhost:8080" , "us-east-1"
2176+ )
2177+
2178+
20512179def test_send_durable_execution_callback_failure_handler_empty_body ():
20522180 """Test SendDurableExecutionCallbackFailureHandler with empty body."""
20532181 executor = Mock ()
0 commit comments