@@ -209,6 +209,42 @@ def test_create_lambda_happycase2(sagemaker_session):
209
209
)
210
210
211
211
212
+ @patch ("sagemaker.lambda_helper._zip_lambda_code" , return_value = ZIPPED_CODE )
213
+ def test_create_lambda_happycase3 (sagemaker_session ):
214
+ lambda_obj = lambda_helper .Lambda (
215
+ function_name = FUNCTION_NAME ,
216
+ execution_role_arn = EXECUTION_ROLE ,
217
+ script = SCRIPT ,
218
+ handler = HANDLER ,
219
+ session = sagemaker_session ,
220
+ architectures = ["x86_64" ],
221
+ environment = {"Name" : "my-test-lambda" },
222
+ vpc_config = {
223
+ "SubnetIds" : ["test-subnet-1" ],
224
+ "SecurityGroupIds" : ["sec-group-1" ]
225
+ }
226
+ )
227
+
228
+ lambda_obj .create ()
229
+ code = {"ZipFile" : ZIPPED_CODE }
230
+
231
+ sagemaker_session .lambda_client .create_function .assert_called_with (
232
+ FunctionName = FUNCTION_NAME ,
233
+ Runtime = "python3.8" ,
234
+ Handler = HANDLER ,
235
+ Role = EXECUTION_ROLE ,
236
+ Code = code ,
237
+ Timeout = 120 ,
238
+ MemorySize = 128 ,
239
+ Architectures = ["x86_64" ],
240
+ VpcConfig = {
241
+ "SubnetIds" : ["test-subnet-1" ],
242
+ "SecurityGroupIds" : ["sec-group-1" ]
243
+ },
244
+ Environment = {"Name" : "my-test-lambda" },
245
+ )
246
+
247
+
212
248
def test_create_lambda_no_function_name_error (sagemaker_session ):
213
249
lambda_obj = lambda_helper .Lambda (
214
250
function_arn = LAMBDA_ARN ,
@@ -280,6 +316,29 @@ def test_update_lambda_happycase2(sagemaker_session):
280
316
)
281
317
282
318
319
+ @patch ("sagemaker.lambda_helper._zip_lambda_code" , return_value = ZIPPED_CODE )
320
+ def test_update_lambda_happycase3 (sagemaker_session ):
321
+ lambda_obj = lambda_helper .Lambda (
322
+ function_name = FUNCTION_NAME ,
323
+ execution_role_arn = EXECUTION_ROLE ,
324
+ script = SCRIPT ,
325
+ handler = HANDLER ,
326
+ session = sagemaker_session ,
327
+ architectures = ["x86_64" ],
328
+ environment = {"Name" : "my-test-lambda" },
329
+ vpc_config = {
330
+ "SubnetIds" : ["test-subnet-1" ],
331
+ "SecurityGroupIds" : ["sec-group-1" ]
332
+ }
333
+ )
334
+
335
+ lambda_obj .update ()
336
+
337
+ sagemaker_session .lambda_client .update_function_code .assert_called_with (
338
+ FunctionName = FUNCTION_NAME , ZipFile = ZIPPED_CODE , Architectures = ["x86_64" ],
339
+ )
340
+
341
+
283
342
@patch ("sagemaker.lambda_helper._zip_lambda_code" , return_value = ZIPPED_CODE )
284
343
def test_update_lambda_client_error (sagemaker_session ):
285
344
lambda_obj = lambda_helper .Lambda (
0 commit comments