Skip to content

Commit 6f13f15

Browse files
committed
Add tests for new parameters added.
1 parent d37df68 commit 6f13f15

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/unit/test_lambda_helper.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,42 @@ def test_create_lambda_happycase2(sagemaker_session):
209209
)
210210

211211

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+
212248
def test_create_lambda_no_function_name_error(sagemaker_session):
213249
lambda_obj = lambda_helper.Lambda(
214250
function_arn=LAMBDA_ARN,
@@ -280,6 +316,29 @@ def test_update_lambda_happycase2(sagemaker_session):
280316
)
281317

282318

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+
283342
@patch("sagemaker.lambda_helper._zip_lambda_code", return_value=ZIPPED_CODE)
284343
def test_update_lambda_client_error(sagemaker_session):
285344
lambda_obj = lambda_helper.Lambda(

0 commit comments

Comments
 (0)