Best Python code snippet using localstack_python
list_aws_resources.py
Source:list_aws_resources.py
...87 self.set_region(region)88 _functions = self.list_functions()89 _aliases = self.list_aliases(_functions)90 _source_mappings = self.list_event_source_mappings()91 _invoke_configs = self.list_function_event_invoke_configs(_functions)92 _versions = self.list_versions_by_function(_functions)93 _layers = self.list_layers()94 _layer_versions = self.list_layer_versions(_layers)95 _provisioned_concurrency_configs = self.list_provisioned_concurrency_configs(_functions)96 _found_count = _found_count + len(_functions) + len(_aliases) + len(_source_mappings) + len(_invoke_configs)97 + len(_versions) + len(_layers) + len(_layer_versions) + len(_provisioned_concurrency_configs)98 print(f"## Resources in {region}")99 print("### Functions")100 pp.pprint(_functions)101 print("### Aliases")102 pp.pprint(_aliases)103 print("### Event Source Mappings")104 pp.pprint(_source_mappings)105 print("### Function Event Invoke Configs")106 pp.pprint(_invoke_configs)107 print("### Versions")108 pp.pprint(_versions)109 print("### Layers")110 pp.pprint(_layers)111 print("### Layer Versions")112 pp.pprint(_layer_versions)113 print("### Provisioned Concurrency Configs")114 pp.pprint(_provisioned_concurrency_configs)115 print (f"## {_found_count} Resources Found Across All Regions")116 def list_aliases(self, functions):117 _aliases = []118 for _function in functions:119 _local_aliases = self.lambda_client.list_aliases(FunctionName=_function["FunctionName"])["Aliases"]120 if len(_local_aliases) > 0:121 _aliases.append({"FuncitonName": _function["FunctionName"], "aliases": _local_aliases})122 return _aliases123 def list_functions(self):124 return self.lambda_client.list_functions()['Functions']125 126 def list_event_source_mappings(self):127 return self.lambda_client.list_event_source_mappings()['EventSourceMappings']128 129 def list_function_event_invoke_configs(self, functions):130 _function_event_invoke_configs = []131 for _function in functions:132 _local_feic = self.lambda_client.list_function_event_invoke_configs(FunctionName=_function["FunctionName"])['FunctionEventInvokeConfigs']133 if len(_local_feic) > 0:134 _function_event_invoke_configs.append({"FunctionName": _function["FunctionName"], 135 "function_event_invoke_configs": _local_feic})136 return _function_event_invoke_configs137 def list_layer_versions(self, layers):138 _layer_versions = []139 for _layer in layers:140 _local_lv = self.lambda_client.list_layer_versions(FunctionName=_layer["LayerName"])['LayerVersion']141 if len(_local_lv) > 0:142 _layer_versions.append({"FunctionName": _function["FunctionName"], 143 "LayerVersions": _local_lv})144 return _layer_versions145 def list_layers(self):146 return self.lambda_client.list_layers()["Layers"]...
lambda_fixtures.py
Source:lambda_fixtures.py
1import boto32import pytest3from moto import mock_lambda4@pytest.fixture5def gen_lambda_client(aws_setup):6 with mock_lambda():7 yield boto3.client("lambda")8# ============================9# WAITER10# ============================11@pytest.fixture12def gen_function_exists_waiter(gen_lambda_client):13 return gen_lambda_client.get_waiter("function_exists")14@pytest.fixture15def gen_function_active_waiter(gen_lambda_client):16 return gen_lambda_client.get_waiter("function_active")17@pytest.fixture18def gen_function_updated_waiter(gen_lambda_client):19 return gen_lambda_client.get_waiter("function_updated")20# ============================21# PAGINATOR22# ============================23@pytest.fixture24def gen_list_event_source_mappings_paginator(gen_lambda_client):25 return gen_lambda_client.get_paginator("list_event_source_mappings")26@pytest.fixture27def gen_list_functions_paginator(gen_lambda_client):28 return gen_lambda_client.get_paginator("list_functions")29@pytest.fixture30def gen_list_aliases_paginator(gen_lambda_client):31 return gen_lambda_client.get_paginator("list_aliases")32@pytest.fixture33def gen_list_layer_versions_paginator(gen_lambda_client):34 return gen_lambda_client.get_paginator("list_layer_versions")35@pytest.fixture36def gen_list_layers_paginator(gen_lambda_client):37 return gen_lambda_client.get_paginator("list_layers")38@pytest.fixture39def gen_list_versions_by_function_paginator(gen_lambda_client):40 return gen_lambda_client.get_paginator("list_versions_by_function")41@pytest.fixture42def gen_list_function_event_invoke_configs_paginator(gen_lambda_client):43 return gen_lambda_client.get_paginator("list_function_event_invoke_configs")44@pytest.fixture45def gen_list_provisioned_concurrency_configs_paginator(gen_lambda_client):46 return gen_lambda_client.get_paginator("list_provisioned_concurrency_configs")47@pytest.fixture48def gen_list_code_signing_configs_paginator(gen_lambda_client):49 return gen_lambda_client.get_paginator("list_code_signing_configs")50@pytest.fixture51def gen_list_functions_by_code_signing_config_paginator(gen_lambda_client):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!