Best Python code snippet using localstack_python
test_network_interfaces.py
Source:test_network_interfaces.py
...341 ni_id = data['NetworkInterface']['NetworkInterfaceId']342 res_clean = self.addResourceCleanUp(343 self.client.delete_network_interface, NetworkInterfaceId=ni_id)344 self.get_network_interface_waiter().wait_available(ni_id)345 data = self.client.describe_network_interface_attribute(346 NetworkInterfaceId=ni_id, Attribute='description')347 self.assertEqual(desc, data['Description']['Value'])348 new_desc = data_utils.rand_name('new-ni')349 self.client.modify_network_interface_attribute(350 NetworkInterfaceId=ni_id, Description={'Value': new_desc})351 data = self.client.describe_network_interface_attribute(352 NetworkInterfaceId=ni_id, Attribute='description')353 self.assertEqual(new_desc, data['Description']['Value'])354 self.client.delete_network_interface(NetworkInterfaceId=ni_id)355 self.cancelResourceCleanUp(res_clean)356 self.get_network_interface_waiter().wait_delete(ni_id)357 def test_network_interface_attribute_source_dest_check(self):358 data = self.client.create_network_interface(SubnetId=self.subnet_id)359 ni_id = data['NetworkInterface']['NetworkInterfaceId']360 res_clean = self.addResourceCleanUp(361 self.client.delete_network_interface, NetworkInterfaceId=ni_id)362 self.get_network_interface_waiter().wait_available(ni_id)363 self.client.modify_network_interface_attribute(364 NetworkInterfaceId=ni_id, SourceDestCheck={'Value': False})365 data = self.client.describe_network_interface_attribute(366 NetworkInterfaceId=ni_id, Attribute='sourceDestCheck')367 self.assertFalse(data['SourceDestCheck']['Value'])368 # NOTE(andrey-mp): ResetNetworkInterfaceAttribute had inadequate json369 # scheme in botocore and doesn't work against Amazon.370 self.client.modify_network_interface_attribute(371 NetworkInterfaceId=ni_id, SourceDestCheck={'Value': True})372 data = self.client.describe_network_interface_attribute(373 NetworkInterfaceId=ni_id, Attribute='sourceDestCheck')374 self.assertEqual(True, data['SourceDestCheck']['Value'])375 self.client.delete_network_interface(NetworkInterfaceId=ni_id)376 self.cancelResourceCleanUp(res_clean)377 self.get_network_interface_waiter().wait_delete(ni_id)378 @testtools.skipUnless(CONF.aws.image_id, "image id is not defined")379 def test_network_interface_attribute_attachment(self):380 instance_id = self.run_instance(SubnetId=self.subnet_id)381 instance = self.get_instance(instance_id)382 nis = instance.get('NetworkInterfaces', [])383 self.assertEqual(1, len(nis))384 self.assertTrue(nis[0]['Attachment']['DeleteOnTermination'])385 ni_id = nis[0]['NetworkInterfaceId']386 data = self.client.describe_network_interface_attribute(387 NetworkInterfaceId=ni_id, Attribute='attachment')388 self.assertIn('Attachment', data)389 self.assertTrue(data['Attachment'].get('AttachmentId'))390 self.assertTrue(data['Attachment'].get('DeleteOnTermination'))391 self.assertEqual(0, data['Attachment'].get('DeviceIndex'))392 self.assertEqual(instance_id, data['Attachment'].get('InstanceId'))393 self.assertEqual('attached', data['Attachment'].get('Status'))394 self.client.terminate_instances(InstanceIds=[instance_id])395 self.get_instance_waiter().wait_delete(instance_id)396 def test_network_interface_attribute_empty_attachment(self):397 data = self.client.create_network_interface(SubnetId=self.subnet_id)398 ni_id = data['NetworkInterface']['NetworkInterfaceId']399 res_clean = self.addResourceCleanUp(400 self.client.delete_network_interface, NetworkInterfaceId=ni_id)401 self.get_network_interface_waiter().wait_available(ni_id)402 data = self.client.describe_network_interface_attribute(403 NetworkInterfaceId=ni_id, Attribute='attachment')404 self.assertNotIn('Attachment', data)405 self.client.delete_network_interface(NetworkInterfaceId=ni_id)406 self.cancelResourceCleanUp(res_clean)407 self.get_network_interface_waiter().wait_delete(ni_id)408 def test_network_interface_attribute_group_set(self):409 data = self.client.create_network_interface(SubnetId=self.subnet_id)410 ni_id = data['NetworkInterface']['NetworkInterfaceId']411 res_clean = self.addResourceCleanUp(412 self.client.delete_network_interface, NetworkInterfaceId=ni_id)413 self.get_network_interface_waiter().wait_available(ni_id)414 data = self.client.describe_network_interface_attribute(415 NetworkInterfaceId=ni_id, Attribute='groupSet')416 self.assertIn('Groups', data)417 self.assertEqual(1, len(data['Groups']))418 self.assertEqual('default', data['Groups'][0]['GroupName'])419 self.client.delete_network_interface(NetworkInterfaceId=ni_id)420 self.cancelResourceCleanUp(res_clean)421 self.get_network_interface_waiter().wait_delete(ni_id)422 def test_instance_attributes_negative(self):423 data = self.client.create_network_interface(SubnetId=self.subnet_id)424 ni_id = data['NetworkInterface']['NetworkInterfaceId']425 res_clean = self.addResourceCleanUp(426 self.client.delete_network_interface, NetworkInterfaceId=ni_id)427 self.get_network_interface_waiter().wait_available(ni_id)428 self.assertRaises('InvalidParameterCombination',...
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!!