Best Python code snippet using tempest_python
test_security_groups.py
Source: test_security_groups.py
...89 if vpc_id:90 self.assertRaises('InvalidPermission.NotFound', del_func, **kwargs)91 else:92 del_func(*[], **kwargs)93 self.client.delete_security_group(GroupId=group_id)94 self.cancelResourceCleanUp(res_clean)95class SecurityGroupInVPCTest(SecurityGroupBaseTest):96 VPC_CIDR = '10.10.0.0/20'97 vpc_id = None98 @classmethod99 @base.safe_setup100 def setUpClass(cls):101 super(SecurityGroupInVPCTest, cls).setUpClass()102 if not base.TesterStateHolder().get_vpc_enabled():103 raise cls.skipException('VPC is disabled')104 data = cls.client.create_vpc(CidrBlock=cls.VPC_CIDR)105 cls.vpc_id = data['Vpc']['VpcId']106 cls.addResourceCleanUpStatic(cls.client.delete_vpc, VpcId=cls.vpc_id)107 cls.get_vpc_waiter().wait_available(cls.vpc_id)108 @decorators.idempotent_id('f8354908-1b3a-4e7b-89e3-6956850bbbfb')109 def test_create_delete_security_group(self):110 name = data_utils.rand_name('sgName')111 desc = data_utils.rand_name('sgDesc')112 data = self.client.create_security_group(VpcId=self.vpc_id,113 GroupName=name,114 Description=desc)115 group_id = data['GroupId']116 res_clean = self.addResourceCleanUp(self.client.delete_security_group,117 GroupId=group_id)118 time.sleep(2)119 self.client.delete_security_group(GroupId=group_id)120 self.cancelResourceCleanUp(res_clean)121 self.assertRaises('InvalidGroup.NotFound',122 self.client.describe_security_groups,123 GroupIds=[group_id])124 self.assertRaises('InvalidGroup.NotFound',125 self.client.delete_security_group,126 GroupId=group_id)127 @decorators.idempotent_id('fe209503-c348-4456-94b4-a77e68fabcbb')128 def test_create_duplicate_security_group(self):129 name = data_utils.rand_name('sgName')130 desc = data_utils.rand_name('sgDesc')131 data = self.client.create_security_group(VpcId=self.vpc_id,132 GroupName=name,133 Description=desc)134 group_id = data['GroupId']135 res_clean = self.addResourceCleanUp(self.client.delete_security_group,136 GroupId=group_id)137 time.sleep(2)138 self.assertRaises('InvalidGroup.Duplicate',139 self.client.create_security_group,140 VpcId=self.vpc_id, GroupName=name, Description=desc)141 data = self.client.delete_security_group(GroupId=group_id)142 self.cancelResourceCleanUp(res_clean)143 @decorators.idempotent_id('ffe5084a-2d05-42d1-ae8d-edcb0af27909')144 def test_create_duplicate_security_group_in_another_vpc(self):145 name = data_utils.rand_name('sgName')146 desc = data_utils.rand_name('sgDesc')147 data = self.client.create_security_group(VpcId=self.vpc_id,148 GroupName=name,149 Description=desc)150 group_id = data['GroupId']151 res_clean = self.addResourceCleanUp(self.client.delete_security_group,152 GroupId=group_id)153 time.sleep(2)154 data = self.client.create_vpc(CidrBlock=self.VPC_CIDR)155 vpc_id = data['Vpc']['VpcId']156 dv_clean = self.addResourceCleanUp(self.client.delete_vpc,157 VpcId=vpc_id)158 data = self.client.create_security_group(VpcId=vpc_id,159 GroupName=name,160 Description=desc)161 time.sleep(2)162 self.client.delete_security_group(GroupId=data['GroupId'])163 self.client.delete_vpc(VpcId=vpc_id)164 self.cancelResourceCleanUp(dv_clean)165 self.get_vpc_waiter().wait_delete(vpc_id)166 data = self.client.delete_security_group(GroupId=group_id)167 self.cancelResourceCleanUp(res_clean)168 @decorators.idempotent_id('524993f7-a8d3-4ffc-bbf1-6a3014377181')169 @testtools.skipUnless(CONF.aws.run_incompatible_tests,170 "MismatchError: 'InvalidParameterValue' != 'ValidationError'")171 def test_create_invalid_name_desc(self):172 valid = data_utils.rand_name('sgName')173 invalid = 'name%"'174 self.assertRaises('InvalidParameterValue',175 self.client.create_security_group,176 VpcId=self.vpc_id, GroupName=invalid,177 Description=valid)178 self.assertRaises('InvalidParameterValue',179 self.client.create_security_group,180 VpcId=self.vpc_id, GroupName=valid,181 Description=invalid)182 self.assertRaises('InvalidParameterValue',183 self.client.create_security_group,184 VpcId=self.vpc_id, GroupName='default',185 Description='default')186 self.assertRaises('MissingParameter',187 self.client.create_security_group,188 VpcId=self.vpc_id, GroupName=valid, Description='')189 self.assertRaises('MissingParameter',190 self.client.create_security_group,191 VpcId=self.vpc_id, GroupName='', Description=valid)192 @decorators.idempotent_id('3460cefd-c759-4738-ba75-b275939aad1d')193 def test_ingress_rules(self):194 self._test_rules(self.client.authorize_security_group_ingress,195 self.client.revoke_security_group_ingress,196 'IpPermissions', self.vpc_id)197 @decorators.idempotent_id('74a5de83-69b4-4cc5-9431-e4c1f691f0c1')198 def test_egress_rules(self):199 self._test_rules(self.client.authorize_security_group_egress,200 self.client.revoke_security_group_egress,201 'IpPermissionsEgress', self.vpc_id)202class SecurityGroupEC2ClassicTest(SecurityGroupBaseTest):203 @classmethod204 @base.safe_setup205 def setUpClass(cls):206 super(SecurityGroupEC2ClassicTest, cls).setUpClass()207 if not base.TesterStateHolder().get_ec2_enabled():208 raise cls.skipException('EC2-classic is disabled')209 @decorators.idempotent_id('eb097f7c-4b10-4365-aa34-c17e5769f4a7')210 def test_create_delete_security_group(self):211 name = data_utils.rand_name('sgName')212 desc = data_utils.rand_name('sgDesc')213 data = self.client.create_security_group(GroupName=name,214 Description=desc)215 group_id = data['GroupId']216 res_clean = self.addResourceCleanUp(self.client.delete_security_group,217 GroupId=group_id)218 time.sleep(2)219 data = self.client.describe_security_groups(GroupNames=[name])220 self.assertEqual(1, len(data['SecurityGroups']))221 self.assertEqual(group_id, data['SecurityGroups'][0]['GroupId'])222 data = self.client.describe_security_groups(GroupIds=[group_id])223 self.assertEqual(1, len(data['SecurityGroups']))224 self.assertEqual(name, data['SecurityGroups'][0]['GroupName'])225 self.client.delete_security_group(GroupName=name)226 self.cancelResourceCleanUp(res_clean)227 @decorators.idempotent_id('b97b8b4a-811e-4584-8e79-086499459aca')228 def test_create_duplicate_security_group(self):229 name = data_utils.rand_name('sgName')230 desc = data_utils.rand_name('sgDesc')231 data = self.client.create_security_group(GroupName=name,232 Description=desc)233 group_id = data['GroupId']234 res_clean = self.addResourceCleanUp(self.client.delete_security_group,235 GroupId=group_id)236 time.sleep(2)237 self.assertRaises('InvalidGroup.Duplicate',238 self.client.create_security_group,239 GroupName=name, Description=desc)240 self.client.delete_security_group(GroupId=group_id)241 self.cancelResourceCleanUp(res_clean)242 @decorators.idempotent_id('b80c578d-0c0d-4c7e-b0ee-a7ed23b6b209')243 @testtools.skipUnless(CONF.aws.run_incompatible_tests,244 "MismatchError: 'MissingParameter' != 'ValidationError'")245 def test_create_invalid_name_desc(self):246 valid = data_utils.rand_name('sgName')247 self.assertRaises('MissingParameter',248 self.client.create_security_group,249 GroupName=valid, Description='')250 self.assertRaises('MissingParameter',251 self.client.create_security_group,252 GroupName='', Description=valid)253 self.assertRaises('InvalidGroup.Reserved',254 self.client.create_security_group,...
ec2_delete.py
Source: ec2_delete.py
...26 response = ec2_client.delete_key_pair(27 KeyName='ec2-demo'28 )29 pprint.pp(response)30def delete_security_group():31 """32 Function deletes the security group from ec2-create.py33 """34 ec2_client = boto3.client("ec2", region_name="us-east-1")35 response = ec2_client.delete_security_group(36 GroupName='EC2_DEMO'37 )38 pprint.pp(response)39print(terminate_instance.__doc__)40terminate_instance(instance_id)41print(delete_key_pair.__doc__)42delete_key_pair()43sleep(60)44print(delete_security_group.__doc__)...
delete_security_group.py
Source: delete_security_group.py
1import boto2import boto.ec23from credentials import *4import time5def delete_security_group():6 conn= boto.connect_ec2(aws_access_key_id=access,aws_secret_access_key=secret)7 region = boto.ec2.connect_to_region('us-west-2')8 s_list = region.get_all_security_groups()9 print(s_list)10 for x in range(1,19):11 if x == 16:12 continue13 s_name = "launch-wizard-"+format(x)14 region.delete_security_group(name=s_name)15 print("Deleted Security group", s_name)16 time.sleep(5)...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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!!