How to use disassociate_address method in localstack

Best Python code snippet using localstack_python

test_address.py

Source:test_address.py Github

copy

Full Screen

1from tests.compat import mock, unittest2from boto.ec2.address import Address3class AddressTest(unittest.TestCase):4 def setUp(self):5 self.address = Address()6 self.address.connection = mock.Mock()7 self.address.public_ip = "192.168.1.1"8 def check_that_attribute_has_been_set(self, name, value, attribute):9 self.address.endElement(name, value, None)10 self.assertEqual(getattr(self.address, attribute), value)11 def test_endElement_sets_correct_attributes_with_values(self):12 for arguments in [("publicIp", "192.168.1.1", "public_ip"),13 ("instanceId", 1, "instance_id"),14 ("domain", "some domain", "domain"),15 ("allocationId", 1, "allocation_id"),16 ("associationId", 1, "association_id"),17 ("somethingRandom", "somethingRandom", "somethingRandom")]:18 self.check_that_attribute_has_been_set(arguments[0], arguments[1], arguments[2])19 def test_release_calls_connection_release_address_with_correct_args(self):20 self.address.release()21 self.address.connection.release_address.assert_called_with(22 public_ip="192.168.1.1",23 dry_run=False24 )25 def test_associate_calls_connection_associate_address_with_correct_args(self):26 self.address.associate(1)27 self.address.connection.associate_address.assert_called_with(28 instance_id=1,29 public_ip="192.168.1.1",30 allow_reassociation=False,31 network_interface_id=None,32 private_ip_address=None,33 dry_run=False34 )35 def test_disassociate_calls_connection_disassociate_address_with_correct_args(self):36 self.address.disassociate()37 self.address.connection.disassociate_address.assert_called_with(38 public_ip="192.168.1.1",39 dry_run=False40 )41class AddressWithAllocationTest(unittest.TestCase):42 def setUp(self):43 self.address = Address()44 self.address.connection = mock.Mock()45 self.address.public_ip = "192.168.1.1"46 self.address.allocation_id = "aid1"47 def check_that_attribute_has_been_set(self, name, value, attribute):48 self.address.endElement(name, value, None)49 self.assertEqual(getattr(self.address, attribute), value)50 def test_endElement_sets_correct_attributes_with_values(self):51 for arguments in [("publicIp", "192.168.1.1", "public_ip"),52 ("instanceId", 1, "instance_id"),53 ("domain", "some domain", "domain"),54 ("allocationId", 1, "allocation_id"),55 ("associationId", 1, "association_id"),56 ("somethingRandom", "somethingRandom", "somethingRandom")]:57 self.check_that_attribute_has_been_set(arguments[0], arguments[1], arguments[2])58 def test_release_calls_connection_release_address_with_correct_args(self):59 self.address.release()60 self.address.connection.release_address.assert_called_with(61 allocation_id="aid1",62 dry_run=False63 )64 def test_associate_calls_connection_associate_address_with_correct_args(self):65 self.address.associate(1)66 self.address.connection.associate_address.assert_called_with(67 instance_id=1,68 public_ip="192.168.1.1",69 allocation_id="aid1",70 network_interface_id=None,71 private_ip_address=None,72 allow_reassociation=False,73 dry_run=False74 )75 def test_disassociate_calls_connection_disassociate_address_with_correct_args(self):76 self.address.disassociate()77 self.address.connection.disassociate_address.assert_called_with(78 public_ip="192.168.1.1",79 dry_run=False80 )81class AddressWithNetworkInterfaceTest(unittest.TestCase):82 def setUp(self):83 self.address = Address()84 self.address.connection = mock.Mock()85 self.address.public_ip = "192.168.1.1"86 self.address.allocation_id = "aid1"87 def check_that_attribute_has_been_set(self, name, value, attribute):88 self.address.endElement(name, value, None)89 self.assertEqual(getattr(self.address, attribute), value)90 def test_endElement_sets_correct_attributes_with_values(self):91 for arguments in [("publicIp", "192.168.1.1", "public_ip"),92 ("instanceId", 1, "instance_id"),93 ("domain", "some domain", "domain"),94 ("allocationId", 1, "allocation_id"),95 ("associationId", 1, "association_id"),96 ("somethingRandom", "somethingRandom", "somethingRandom")]:97 self.check_that_attribute_has_been_set(arguments[0], arguments[1], arguments[2])98 def test_release_calls_connection_release_address_with_correct_args(self):99 self.address.release()100 self.address.connection.release_address.assert_called_with(101 allocation_id="aid1",102 dry_run=False103 )104 def test_associate_calls_connection_associate_address_with_correct_args(self):105 self.address.associate(network_interface_id=1)106 self.address.connection.associate_address.assert_called_with(107 instance_id=None,108 public_ip="192.168.1.1",109 network_interface_id=1,110 private_ip_address=None,111 allocation_id="aid1",112 allow_reassociation=False,113 dry_run=False114 )115 def test_disassociate_calls_connection_disassociate_address_with_correct_args(self):116 self.address.disassociate()117 self.address.connection.disassociate_address.assert_called_with(118 public_ip="192.168.1.1",119 dry_run=False120 )121if __name__ == "__main__":...

Full Screen

Full Screen

address.py

Source:address.py Github

copy

Full Screen

...103 Disassociate this Elastic IP address from a currently running instance.104 :see: :meth:`boto.ec2.connection.EC2Connection.disassociate_address`105 """106 if self.association_id:107 return self.connection.disassociate_address(108 None,109 self.association_id,110 dry_run=dry_run111 )112 else:113 return self.connection.disassociate_address(114 self.public_ip,115 dry_run=dry_run...

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