How to use list_function_versions method in localstack

Best Python code snippet using localstack_python

test_core.py

Source:test_core.py Github

copy

Full Screen

1import pytest2import core3from boto3.exceptions import botocore4from botocore.exceptions import ClientError5def test_list_function_versions(mocker):6 mocker.patch.object(core.LAMBDA_CLIENT, 'list_versions_by_function')7 core.list_function_versions()8 core.LAMBDA_CLIENT.list_versions_by_function.assert_called_with(FunctionName='test function', MaxItems=100)9def test_list_function_versions_return_none(mocker):10 mocker.patch.object(core.LAMBDA_CLIENT, 'list_versions_by_function')11 core.LAMBDA_CLIENT.list_versions_by_function.side_effect = ClientError({'Error': {'Code': 'ResourceNotFoundException'}}, 'list_versions_by_function')12 assert core.list_function_versions() == None13def test_versions_to_delete_none(mocker):14 versions_response = {15 'Versions': [16 { 'Version': '$LATEST', 'LastModified': 100},17 { 'Version': 2, 'LastModified': 99}18 ]19 }20 assert core.versions_to_delete(versions_response) == None21def test_versions_to_delete_less_than_10(mocker):22 versions_response = {23 'Versions': [24 { 'Version': '$LATEST', 'LastModified': 100},25 { 'Version': 2, 'LastModified': 99},26 { 'Version': 3, 'LastModified': 98},...

Full Screen

Full Screen

test_lambdaversionsdeleter.py

Source:test_lambdaversionsdeleter.py Github

copy

Full Screen

1import pytest2import lambdaversionsdeleter3from boto3.exceptions import botocore4from botocore.exceptions import ClientError5import core6def test_handler(mocker):7 mocker.patch.object(core, 'list_function_versions')8 mocker.patch.object(core, 'versions_to_delete', return_value=[1, 2, 3])9 mocker.patch.object(core, 'delete_function_version')10 lambdaversionsdeleter.handler({}, None)11 12 core.list_function_versions.assert_called_once()13 core.versions_to_delete.assert_called_once()14 core.delete_function_version.assert_any_call(1)15 core.delete_function_version.assert_any_call(2)16 core.delete_function_version.assert_any_call(3)17def test_handler_versions_to_delete_not_called(mocker):18 mocker.patch.object(core, 'list_function_versions')19 mocker.patch.object(core, 'versions_to_delete')20 core.list_function_versions.return_value = None21 lambdaversionsdeleter.handler({}, None)22 23 core.list_function_versions.assert_called_once()24 core.versions_to_delete.assert_not_called()25def test_handler_delete_not_called(mocker):26 mocker.patch.object(core, 'list_function_versions')27 mocker.patch.object(core, 'versions_to_delete', return_value=None)28 mocker.patch.object(core, 'delete_function_version')29 lambdaversionsdeleter.handler({}, None)30 31 core.list_function_versions.assert_called_once()32 core.versions_to_delete.assert_called_once()...

Full Screen

Full Screen

lambdaversionsdeleter.py

Source:lambdaversionsdeleter.py Github

copy

Full Screen

...6LOG = lambdalogging.getLogger(__name__)7def handler(event, context):8 """Delete lambda function versions for the lambda function mentioned in environment variables."""9 LOG.info('Received event: %s', event)10 function_versions = core.list_function_versions()11 if not function_versions:12 LOG.info("Skipping...")13 return14 versions_to_delete = core.versions_to_delete(function_versions)15 if versions_to_delete:16 for version_num in versions_to_delete:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful