Best Python code snippet using localstack_python
test_ec2.py
Source: test_ec2.py
1# Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# http://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License.13import itertools14import botocore.session15from botocore.exceptions import ClientError16from tests import unittest17class TestEC2(unittest.TestCase):18 def setUp(self):19 self.session = botocore.session.get_session()20 self.client = self.session.create_client(21 'ec2', region_name='us-west-2'22 )23 def test_can_make_request(self):24 # Basic smoke test to ensure we can talk to ec2.25 result = self.client.describe_availability_zones()26 zones = list(27 sorted(a['ZoneName'] for a in result['AvailabilityZones'])28 )29 self.assertTrue(30 {'us-west-2a', 'us-west-2b', 'us-west-2c'}.issubset(zones)31 )32 def test_get_console_output_handles_error(self):33 # Want to ensure the underlying ClientError is propogated34 # on error.35 with self.assertRaises(ClientError):36 self.client.get_console_output(InstanceId='i-12345')37class TestEC2Pagination(unittest.TestCase):38 def setUp(self):39 self.session = botocore.session.get_session()40 self.client = self.session.create_client(41 'ec2', region_name='us-west-2'42 )43 def test_can_paginate(self):44 # Using an operation that we know will paginate.45 paginator = self.client.get_paginator(46 'describe_reserved_instances_offerings'47 )48 pages = paginator.paginate()49 results = list(itertools.islice(pages, 0, 3))50 self.assertEqual(len(results), 3)51 self.assertTrue(results[0]['NextToken'] != results[1]['NextToken'])52 def test_can_paginate_with_page_size(self):53 # Using an operation that we know will paginate.54 paginator = self.client.get_paginator(55 'describe_reserved_instances_offerings'56 )57 pages = paginator.paginate(PaginationConfig={'PageSize': 1})58 results = list(itertools.islice(pages, 0, 3))59 self.assertEqual(len(results), 3)60 for parsed in results:61 reserved_inst_offer = parsed['ReservedInstancesOfferings']62 # There should be no more than one reserved instance63 # offering on each page.64 self.assertLessEqual(len(reserved_inst_offer), 1)65 def test_can_fall_back_to_old_starting_token(self):66 # Using an operation that we know will paginate.67 paginator = self.client.get_paginator(68 'describe_reserved_instances_offerings'69 )70 pages = paginator.paginate(PaginationConfig={'NextToken': 'None___1'})71 try:72 results = list(itertools.islice(pages, 0, 3))73 self.assertEqual(len(results), 3)74 self.assertTrue(results[0]['NextToken'] != results[1]['NextToken'])75 except ValueError:76 self.fail("Old style paginator failed.")77if __name__ == '__main__':...
reserved_instances.py
Source: reserved_instances.py
...17 def describe_reserved_instances_listings(self):18 raise NotImplementedError(19 "ReservedInstances.describe_reserved_instances_listings is not yet implemented"20 )21 def describe_reserved_instances_offerings(self):22 raise NotImplementedError(23 "ReservedInstances.describe_reserved_instances_offerings is not yet implemented"24 )25 def purchase_reserved_instances_offering(self):26 if self.is_not_dryrun("PurchaseReservedInstances"):27 raise NotImplementedError(28 "ReservedInstances.purchase_reserved_instances_offering is not yet implemented"...
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!!