Best Python code snippet using localstack_python
apigateway_listener.py
Source:apigateway_listener.py
...43 integration = integration.get('methodIntegration')44 if not integration:45 if method == 'OPTIONS' and 'Origin' in headers:46 # default to returning CORS headers if this is an OPTIONS request47 return get_cors_response(headers)48 return make_error('Unable to find integration for path %s' % path, 404)49 uri = integration.get('uri')50 if method == 'POST' and integration['type'] == 'AWS':51 if uri.endswith('kinesis:action/PutRecords'):52 template = integration['requestTemplates'][APPLICATION_JSON]53 new_request = aws_stack.render_velocity_template(template, data)54 # forward records to target kinesis stream55 headers = aws_stack.mock_aws_request_headers(service='kinesis')56 headers['X-Amz-Target'] = kinesis_listener.ACTION_PUT_RECORDS57 result = common.make_http_request(url=TEST_KINESIS_URL,58 method='POST', data=new_request, headers=headers)59 return result60 else:61 msg = 'API Gateway action uri "%s" not yet implemented' % uri...
upload.py
Source:upload.py
...26 bucket.create('private')27 bucket.put_object(Body=file_content_byte_array, Key=file_key)28 result = get_aws_api_response(200)29 return result30def get_cors_response():31 return {32 'statusCode': 200,33 'headers': {34 "Access-Control-Allow-Origin": "*",35 "Access-Control-Allow-Credentials": 'true',36 'Content-Type': 'text/html',37 'Access-Control-Allow-Headers': 'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'38 },39 }40def get_aws_api_response(status_code, response_body=None):41 return {42 'statusCode': status_code,43 'body': json.dumps(response_body.__dict__) if response_body else json.dumps({}),44 'headers': {...
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!!