Best Python code snippet using localstack_python
deployment_helper.py
Source: deployment_helper.py
...45 aws_access_key_id=self.aws_access_key_id,46 aws_secret_access_key = self.aws_secret_access_key,47 region_name=self.aws_region48 )49 def put_rest_api(self):50 """Reimport api swagger file to AWS api gateway51 """52 # Retrieve content of the api swagger template53 with open(self.api_json_file, 'rb') as fp:54 data = fp.read()55 print("Reimport API swagger file to api gateway [{}] ...".format(self.aws_restapiid))56 resp = self.client.put_rest_api(restApiId=self.aws_restapiid, mode='overwrite', body=data)57 print('Response:\n{}'.format(json.dumps(resp, cls=DefaultEncoder, indent=2)))58 return resp['ResponseMetadata']['HTTPStatusCode'] in HTTPS_OK_CODES59 def create_deployment(self, stage_name, bucket_name, cache_enabled, cache_size):60 """Create or update a deployment stage61 """62 print("Create or update deployment stage [{}] of api gateway [{}] ...".format(stage_name, self.aws_restapiid))63 resp = self.client.create_deployment(64 restApiId=self.aws_restapiid,65 stageName=stage_name,66 stageDescription=stage_name,67 description=stage_name, # TODO a proper description instead of using the stage name68 cacheClusterEnabled=bool(cache_enabled),69 cacheClusterSize=cache_size,70 variables={71 'bucket': bucket_name72 }73 )74 print('Response:\n{}'.format(json.dumps(resp, cls=DefaultEncoder, indent=2)))75 return resp['ResponseMetadata']['HTTPStatusCode'] in HTTPS_OK_CODES76def main():77 # Retrieve what action to be done from command line78 parser = argparse.ArgumentParser(79 description="Reimport the API Swagger template to AWS and run tests. "\80 + "If `deploy` is specified, the program will instead deploy the "\81 + "current rest api to the specified stage and tested."82 )83 parser.add_argument('--deploy', help="Deploy the current rest api to a stage. Choices: [test, stage, prod]")84 args = parser.parse_args(sys.argv[1:])85 # Retrieve AWS resource settings from the ini file86 config = configparser.ConfigParser()87 config.read(SETTINGS['ini_file'])88 SETTINGS['aws_restapiid'] = config['default']['aws.apigateway.restApiId']89 helper = ApiGatewayHelper(SETTINGS)90 if args.deploy is None:91 # Put the restapi to AWS92 if helper.put_rest_api() is False:93 logging.error("Failed to reimport the api swagger file. Aborted")94 return 195 else:96 # Retrieve stage-specific settings97 stage_name = args.deploy.lower()98 profile = stage_name if stage_name in config.sections() else 'test'99 s3 = config[profile]['aws.s3']100 cache_enabled = True if config[profile]['aws.apigateway.cacheClusterEnabled'].lower() == 'true' else False101 cache_size = config[profile]['aws.apigateway.cacheClusterSize']102 if helper.create_deployment(stage_name, s3, cache_enabled, cache_size) is False:103 logging.error("Failed to create deployment stage. Aborted")104 return 1105 return 0106if __name__ == '__main__':...
apigateway.py
Source: apigateway.py
...28 defs = {k: v for k, v in getattr(xargs, 'def') or []}29 data = load(xargs.template)30 data = template.render(data, defs=defs)31 dump(data, xargs.swagger)32def put_rest_api(args=None):33 """34 import swagger to Gateway API35 :param args:36 :return:37 """38 xargs = parse_arguments('aws.apigateway.put-rest-api', args=args)39 print("Importing Swagger to API Gateway: %s" % (xargs.swagger,))40 # read file41 with open(xargs.swagger) as f:42 body = f.read()43 # put rest api definition44 AWSSession().client('apigateway').put_rest_api(45 restApiId=xargs.rest_api_id,46 mode='overwrite',47 failOnWarnings=True,48 body=body...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!