How to use load_spec_patches method in localstack

Best Python code snippet using localstack_python

spec.py

Source:spec.py Github

copy

Full Screen

...8from botocore.loaders import Loader, instance_cache9from botocore.model import OperationModel, ServiceModel10ServiceName = str11spec_patches_json = os.path.join(os.path.dirname(__file__), "spec-patches.json")12def load_spec_patches() -> Dict[str, list]:13 if not os.path.exists(spec_patches_json):14 return {}15 with open(spec_patches_json) as fd:16 return json.load(fd)17class PatchingLoader(Loader):18 """19 A custom botocore Loader that applies JSON patches from the given json patch file to the specs as they are loaded.20 """21 patches: Dict[str, list]22 def __init__(self, patches: Dict[str, list], *args, **kwargs):23 super().__init__(*args, **kwargs)24 self.patches = patches25 @instance_cache26 def load_data(self, name: str):27 result = super(PatchingLoader, self).load_data(name)28 if patches := self.patches.get(name):29 return jsonpatch.apply_patch(result, patches)30 return result31loader = PatchingLoader(load_spec_patches())32def list_services(model_type="service-2") -> List[ServiceModel]:33 return [load_service(service) for service in loader.list_available_services(model_type)]34def load_service(service: ServiceName, version: str = None, model_type="service-2") -> ServiceModel:35 """36 For example: load_service("sqs", "2012-11-05")37 """38 service_description = loader.load_service_model(service, model_type, version)39 return ServiceModel(service_description, service)40def iterate_service_operations() -> Generator[Tuple[ServiceModel, OperationModel], None, None]:41 """42 Returns one record per operation in the AWS service spec, where the first item is the service model the operation43 belongs to, and the second is the operation model.44 :return: an iterable45 """...

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