Best Python code snippet using localstack_python
test_amazon_driver.py
Source:test_amazon_driver.py  
...270        self.fake_driver.client.delete_subnet.\271            assert_called_once_with(SubnetId='subnet-9dcb6b38')272        self.fake_driver.client.delete_vpc.\273            assert_called_once_with(VpcId='vpc-5eed72c5')274    def test_delete_unable_to_describe_subnets(self):275        self.mock_object(276            self.fake_driver.client, 'describe_subnets',277            mock.Mock(side_effect=ClientError(278                fake_error_code,279                'operation_name'280            )281            ))282        self.mock_object(self.fake_driver.client,283            'delete_subnet', mock.Mock())284        self.mock_object(self.fake_driver.client,285                         'delete_vpc', mock.Mock())286        self.assertRaises(ClientError, self.fake_driver.delete,287                          'subnet-9dcb6b38')288        self.fake_driver.client.describe_subnets.\...09.VPCSubnetDescribe.py
Source:09.VPCSubnetDescribe.py  
...7logger = logging.getLogger()8logging.basicConfig(level=logging.INFO,9                    format='%(asctime)s: %(levelname)s: %(message)s')10vpc_client = boto3.client("ec2", region_name=AWS_REGION)11def describe_subnets(tag, tag_values, max_items):12    """13    Describes one or more of your Subnets.14    """15    try:16        # creating paginator object for describe_subnets() method17        paginator = vpc_client.get_paginator('describe_subnets')18        # creating a PageIterator from the paginator19        response_iterator = paginator.paginate(20            Filters=[{21                'Name': f'tag:{tag}',22                'Values': tag_values23            }],24            PaginationConfig={'MaxItems': max_items})25        full_result = response_iterator.build_full_result()26        subnet_list = []27        for page in full_result['Subnets']:28            subnet_list.append(page)29    except ClientError:30        logger.exception('Could not describe subnets.')31        raise32    else:33        return subnet_list34if __name__ == '__main__':35    # Constants36    TAG = 'Name'37    TAG_VALUES = ['hands-on-cloud-custom-subnet']38    MAX_ITEMS = 1039    subnets = describe_subnets(TAG, TAG_VALUES, MAX_ITEMS)40    logger.info('Subnet Details: ')41    for subnet in subnets:...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!!
