@@ -97,6 +97,19 @@ def test_generic_method_not_allowed(self, service_response_mock):
9797 405 ,
9898 )
9999
100+ @patch ("samcli.local.services.base_local_service.BaseLocalService.service_response" )
101+ def test_validation_exception (self , service_response_mock ):
102+ service_response_mock .return_value = "ValidationException"
103+
104+ response = LambdaErrorResponses .validation_exception ("ValidationException" )
105+
106+ self .assertEqual (response , "ValidationException" )
107+ service_response_mock .assert_called_once_with (
108+ '{"Type": "User", "Message": "ValidationException"}' ,
109+ {"x-amzn-errortype" : "ValidationException" , "Content-Type" : "application/json" },
110+ 400 ,
111+ )
112+
100113 @patch ("samcli.local.services.base_local_service.BaseLocalService.service_response" )
101114 def test_durable_execution_not_found (self , service_response_mock ):
102115 service_response_mock .return_value = "DurableExecutionNotFound"
@@ -109,3 +122,16 @@ def test_durable_execution_not_found(self, service_response_mock):
109122 {"x-amzn-errortype" : "ResourceNotFound" , "Content-Type" : "application/json" },
110123 404 ,
111124 )
125+
126+ @patch ("samcli.local.services.base_local_service.BaseLocalService.service_response" )
127+ def test_container_creation_failed (self , service_response_mock ):
128+ service_response_mock .return_value = "ContainerCreationFailed"
129+
130+ response = LambdaErrorResponses .container_creation_failed ("Container creation failed: test message" )
131+
132+ self .assertEqual (response , "ContainerCreationFailed" )
133+ service_response_mock .assert_called_once_with (
134+ '{"Type": "LocalService", "Message": "Container creation failed: test message"}' ,
135+ {"x-amzn-errortype" : "ContainerCreationFailed" , "Content-Type" : "application/json" },
136+ 501 ,
137+ )
0 commit comments