How to use detach_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 self.client.delete_internet_gateway, InternetGatewayId=gw_id)49 self.assertEmpty(data['InternetGateway'].get('Attachments', []))50 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,51 InternetGatewayId=gw_id)52 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,53 InternetGatewayId=gw_id)54 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)55 self.cancelResourceCleanUp(res_clean)56 self.assertRaises('InvalidInternetGatewayID.NotFound',57 self.client.describe_internet_gateways,58 InternetGatewayIds=[gw_id])59 @decorators.idempotent_id('f092b63d-9460-4d8f-ba8a-bcd380666033')60 def test_delete_attached_internet_gateway(self):61 data = self.client.create_internet_gateway()62 gw_id = data['InternetGateway']['InternetGatewayId']63 res_clean = self.addResourceCleanUp(64 self.client.delete_internet_gateway, InternetGatewayId=gw_id)65 self.assertEmpty(data['InternetGateway'].get('Attachments', []))66 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,67 InternetGatewayId=gw_id)68 self.assertRaises('DependencyViolation',69 self.client.delete_internet_gateway,70 InternetGatewayId=gw_id)71 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,72 InternetGatewayId=gw_id)73 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)74 self.cancelResourceCleanUp(res_clean)75 @decorators.idempotent_id('89700013-5753-4608-8245-4fc99fbb67ea')76 @testtools.skipUnless(CONF.aws.run_incompatible_tests,77 "Another error code returned - InvalidParameterValue")78 def test_attach_detach_invalid_internet_gateway(self):79 gw_id = "gw-1"80 self.assertRaises('InvalidInternetGatewayID.NotFound',81 self.client.attach_internet_gateway,82 VpcId=self.vpc_id, InternetGatewayId=gw_id)83 self.assertRaises('InvalidInternetGatewayID.NotFound',84 self.client.detach_internet_gateway,85 VpcId=self.vpc_id, InternetGatewayId=gw_id)86 @decorators.idempotent_id('e3e4d8c4-8f62-43e8-a24d-bfd292b4144c')87 def test_double_attach_internet_gateway(self):88 data = self.client.create_internet_gateway()89 gw_id = data['InternetGateway']['InternetGatewayId']90 res_clean = self.addResourceCleanUp(91 self.client.delete_internet_gateway, InternetGatewayId=gw_id)92 self.assertEmpty(data['InternetGateway'].get('Attachments', []))93 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,94 InternetGatewayId=gw_id)95 self.assertRaises('Resource.AlreadyAssociated',96 self.client.attach_internet_gateway,97 VpcId=self.vpc_id, InternetGatewayId=gw_id)98 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,99 InternetGatewayId=gw_id)100 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)101 self.cancelResourceCleanUp(res_clean)102 @decorators.idempotent_id('d8f3a488-a4ba-4ed5-998c-3dc6f43d6d9e')103 def test_attach_one_internet_gateway_to_two_vpcs(self):104 data = self.client.create_internet_gateway()105 gw_id = data['InternetGateway']['InternetGatewayId']106 res_clean = self.addResourceCleanUp(107 self.client.delete_internet_gateway, InternetGatewayId=gw_id)108 self.assertEmpty(data['InternetGateway'].get('Attachments', []))109 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,110 InternetGatewayId=gw_id)111 self.assertRaises('Resource.AlreadyAssociated',112 self.client.attach_internet_gateway,113 VpcId=self.vpc_id_alt, InternetGatewayId=gw_id)114 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,115 InternetGatewayId=gw_id)116 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)117 self.cancelResourceCleanUp(res_clean)118 @decorators.idempotent_id('b86f338c-613e-4cd7-9742-07c86864b0da')119 def test_describe_internet_gateways_base(self):120 data = self.client.create_internet_gateway()121 gw_id = data['InternetGateway']['InternetGatewayId']122 res_clean = self.addResourceCleanUp(123 self.client.delete_internet_gateway, InternetGatewayId=gw_id)124 self.assertEmpty(data['InternetGateway'].get('Attachments', []))125 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,126 InternetGatewayId=gw_id)127 self.addResourceCleanUp(self.client.detach_internet_gateway,128 VpcId=self.vpc_id,129 InternetGatewayId=gw_id)130 time.sleep(2)131 # NOTE(andrey-mp): by real id132 data = self.client.describe_internet_gateways(133 InternetGatewayIds=[gw_id])134 self.assertEqual(1, len(data['InternetGateways']))135 # NOTE(andrey-mp): by fake id136 self.assertRaises('InvalidInternetGatewayID.NotFound',137 self.client.describe_internet_gateways,138 InternetGatewayIds=['igw-0'])139 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,140 InternetGatewayId=gw_id)141 data = self.client.delete_internet_gateway(InternetGatewayId=gw_id)142 self.cancelResourceCleanUp(res_clean)143 @decorators.idempotent_id('3f141c56-9ee6-46bf-9c14-0d922ed8a482')144 def test_describe_internet_gateways_filters(self):145 # NOTE(andrey-mp): by filter real vpc-id before creation146 data = self.client.describe_internet_gateways(147 Filters=[{'Name': 'attachment.vpc-id', 'Values': [self.vpc_id]}])148 self.assertEqual(0, len(data['InternetGateways']))149 data = self.client.create_internet_gateway()150 gw_id = data['InternetGateway']['InternetGatewayId']151 res_clean = self.addResourceCleanUp(152 self.client.delete_internet_gateway, InternetGatewayId=gw_id)153 self.assertEmpty(data['InternetGateway'].get('Attachments', []))154 data = self.client.attach_internet_gateway(VpcId=self.vpc_id,155 InternetGatewayId=gw_id)156 self.addResourceCleanUp(self.client.detach_internet_gateway,157 VpcId=self.vpc_id,158 InternetGatewayId=gw_id)159 time.sleep(2)160 # NOTE(andrey-mp): by filter real vpc-id161 data = self.client.describe_internet_gateways(162 Filters=[{'Name': 'attachment.vpc-id', 'Values': [self.vpc_id]}])163 self.assertEqual(1, len(data['InternetGateways']))164 self.assertEqual(gw_id,165 data['InternetGateways'][0]['InternetGatewayId'])166 # NOTE(andrey-mp): by filter fake vpc-id167 data = self.client.describe_internet_gateways(168 Filters=[{'Name': 'attachment.vpc-id', 'Values': ['vpc-0']}])169 self.assertEqual(0, len(data['InternetGateways']))170 # NOTE(andrey-mp): by fake filter171 self.assertRaises('InvalidParameterValue',172 self.client.describe_internet_gateways,173 Filters=[{'Name': 'fake', 'Values': ['fake']}])174 data = self.client.detach_internet_gateway(VpcId=self.vpc_id,175 InternetGatewayId=gw_id)176 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