How to use delete_internet_gateway method in localstack

Best Python code snippet using localstack_python

test_internet_gateways.py

Source:test_internet_gateways.py Github

copy

Full Screen

...48 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,49 InternetGatewayId=gw_id)50 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,51 InternetGatewayId=gw_id)52 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)53 self.cancelResourceCleanUp(res_clean)54 self.assertRaises('InvalidInternetGatewayID.NotFound',55 self.client.describe_internet_gateways,56 InternetGatewayIds=[gw_id])57 def test_delete_attached_internet_gateway(self):58 data = self.client.create_internet_gateway()59 gw_id = data['InternetGateway']['InternetGatewayId']60 res_clean = self.addResourceCleanUp(61 self.client.delete_internet_gateway, InternetGatewayId=gw_id)62 self.assertEmpty(data['InternetGateway'].get('Attachments', []))63 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,64 InternetGatewayId=gw_id)65 self.assertRaises('DependencyViolation',66 self.client.delete_internet_gateway,67 InternetGatewayId=gw_id)68 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,69 InternetGatewayId=gw_id)70 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)71 self.cancelResourceCleanUp(res_clean)72 @testtools.skipUnless(CONF.aws.run_incompatible_tests,73 "Another error code returned - InvalidParameterValue")74 def test_attach_detach_invalid_internet_gateway(self):75 gw_id = "gw-1"76 self.assertRaises('InvalidInternetGatewayID.NotFound',77 self.client.attach_internet_gateway,78 VpcId=self.vpc_id, InternetGatewayId=gw_id)79 self.assertRaises('InvalidInternetGatewayID.NotFound',80 self.client.detach_internet_gateway,81 VpcId=self.vpc_id, InternetGatewayId=gw_id)82 def test_double_attach_internet_gateway(self):83 data = self.client.create_internet_gateway()84 gw_id = data['InternetGateway']['InternetGatewayId']85 res_clean = self.addResourceCleanUp(86 self.client.delete_internet_gateway, InternetGatewayId=gw_id)87 self.assertEmpty(data['InternetGateway'].get('Attachments', []))88 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,89 InternetGatewayId=gw_id)90 self.assertRaises('Resource.AlreadyAssociated',91 self.client.attach_internet_gateway,92 VpcId=self.vpc_id, InternetGatewayId=gw_id)93 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,94 InternetGatewayId=gw_id)95 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)96 self.cancelResourceCleanUp(res_clean)97 def test_attach_one_internet_gateway_to_two_vpcs(self):98 data = self.client.create_internet_gateway()99 gw_id = data['InternetGateway']['InternetGatewayId']100 res_clean = self.addResourceCleanUp(101 self.client.delete_internet_gateway, InternetGatewayId=gw_id)102 self.assertEmpty(data['InternetGateway'].get('Attachments', []))103 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,104 InternetGatewayId=gw_id)105 self.assertRaises('Resource.AlreadyAssociated',106 self.client.attach_internet_gateway,107 VpcId=self.vpc_id_alt, InternetGatewayId=gw_id)108 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,109 InternetGatewayId=gw_id)110 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)111 self.cancelResourceCleanUp(res_clean)112 def test_describe_internet_gateways_base(self):113 data = self.client.create_internet_gateway()114 gw_id = data['InternetGateway']['InternetGatewayId']115 res_clean = self.addResourceCleanUp(116 self.client.delete_internet_gateway, InternetGatewayId=gw_id)117 self.assertEmpty(data['InternetGateway'].get('Attachments', []))118 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,119 InternetGatewayId=gw_id)120 self.addResourceCleanUp(self.client.detach_internet_gateway,121 VpcId=self.vpc_id,122 InternetGatewayId=gw_id)123 time.sleep(2)124 # NOTE(andrey-mp): by real id125 data = self.client.describe_internet_gateways(126 InternetGatewayIds=[gw_id])127 self.assertEqual(1, len(data['InternetGateways']))128 # NOTE(andrey-mp): by fake id129 self.assertRaises('InvalidInternetGatewayID.NotFound',130 self.client.describe_internet_gateways,131 InternetGatewayIds=['igw-0'])132 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,133 InternetGatewayId=gw_id)134 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)135 self.cancelResourceCleanUp(res_clean)136 def test_describe_internet_gateways_filters(self):137 # NOTE(andrey-mp): by filter real vpc-id before creation138 data = self.client.describe_internet_gateways(139 Filters=[{'Name': 'attachment.vpc-id', 'Values': [self.vpc_id]}])140 self.assertEqual(0, len(data['InternetGateways']))141 data = self.client.create_internet_gateway()142 gw_id = data['InternetGateway']['InternetGatewayId']143 res_clean = self.addResourceCleanUp(144 self.client.delete_internet_gateway, InternetGatewayId=gw_id)145 self.assertEmpty(data['InternetGateway'].get('Attachments', []))146 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,147 InternetGatewayId=gw_id)148 self.addResourceCleanUp(self.client.detach_internet_gateway,149 VpcId=self.vpc_id,150 InternetGatewayId=gw_id)151 time.sleep(2)152 # NOTE(andrey-mp): by filter real vpc-id153 data = self.client.describe_internet_gateways(154 Filters=[{'Name': 'attachment.vpc-id', 'Values': [self.vpc_id]}])155 self.assertEqual(1, len(data['InternetGateways']))156 self.assertEqual(gw_id,157 data['InternetGateways'][0]['InternetGatewayId'])158 # NOTE(andrey-mp): by filter fake vpc-id159 data = self.client.describe_internet_gateways(160 Filters=[{'Name': 'attachment.vpc-id', 'Values': ['vpc-0']}])161 self.assertEqual(0, len(data['InternetGateways']))162 # NOTE(andrey-mp): by fake filter163 self.assertRaises('InvalidParameterValue',164 self.client.describe_internet_gateways,165 Filters=[{'Name': 'fake', 'Values': ['fake']}])166 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,167 InternetGatewayId=gw_id)168 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful