How to use update_floatingip method in tempest

Best Python code snippet using tempest_python

test_floating_ips.py

Source:test_floating_ips.py Github

copy

Full Screen

...86 for f in floating_ips['floatingips']:87 floatingip_id_list.append(f['id'])88 self.assertIn(created_floating_ip['id'], floatingip_id_list)89 # Associate floating IP to the other port90 floating_ip = self.client.update_floatingip(91 created_floating_ip['id'],92 port_id=self.ports[1]['id'])93 updated_floating_ip = floating_ip['floatingip']94 self.assertEqual(updated_floating_ip['port_id'], self.ports[1]['id'])95 self.assertEqual(updated_floating_ip['fixed_ip_address'],96 self.ports[1]['fixed_ips'][0]['ip_address'])97 self.assertEqual(updated_floating_ip['router_id'], self.router['id'])98 # Disassociate floating IP from the port99 floating_ip = self.client.update_floatingip(100 created_floating_ip['id'],101 port_id=None)102 updated_floating_ip = floating_ip['floatingip']103 self.assertIsNone(updated_floating_ip['port_id'])104 self.assertIsNone(updated_floating_ip['fixed_ip_address'])105 self.assertIsNone(updated_floating_ip['router_id'])106 @test.attr(type='smoke')107 def test_floating_ip_delete_port(self):108 # Create a floating IP109 body = self.client.create_floatingip(110 floating_network_id=self.ext_net_id)111 created_floating_ip = body['floatingip']112 self.addCleanup(self.client.delete_floatingip,113 created_floating_ip['id'])114 # Create a port115 port = self.client.create_port(network_id=self.network['id'])116 created_port = port['port']117 floating_ip = self.client.update_floatingip(118 created_floating_ip['id'],119 port_id=created_port['id'])120 # Delete port121 self.client.delete_port(created_port['id'])122 # Verifies the details of the floating_ip123 floating_ip = self.client.show_floatingip(created_floating_ip['id'])124 shown_floating_ip = floating_ip['floatingip']125 # Confirm the fields are back to None126 self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])127 self.assertIsNone(shown_floating_ip['port_id'])128 self.assertIsNone(shown_floating_ip['fixed_ip_address'])129 self.assertIsNone(shown_floating_ip['router_id'])130 @test.attr(type='smoke')131 def test_floating_ip_update_different_router(self):132 # Associate a floating IP to a port on a router133 body = self.client.create_floatingip(134 floating_network_id=self.ext_net_id,135 port_id=self.ports[1]['id'])136 created_floating_ip = body['floatingip']137 self.addCleanup(self.client.delete_floatingip,138 created_floating_ip['id'])139 self.assertEqual(created_floating_ip['router_id'], self.router['id'])140 network2 = self.create_network()141 subnet2 = self.create_subnet(network2)142 router2 = self.create_router(data_utils.rand_name('router-'),143 external_network_id=self.ext_net_id)144 self.create_router_interface(router2['id'], subnet2['id'])145 port_other_router = self.create_port(network2)146 # Associate floating IP to the other port on another router147 floating_ip = self.client.update_floatingip(148 created_floating_ip['id'],149 port_id=port_other_router['id'])150 updated_floating_ip = floating_ip['floatingip']151 self.assertEqual(updated_floating_ip['router_id'], router2['id'])152 self.assertEqual(updated_floating_ip['port_id'],153 port_other_router['id'])154 self.assertIsNotNone(updated_floating_ip['fixed_ip_address'])155 @test.attr(type='smoke')156 def test_create_floating_ip_specifying_a_fixed_ip_address(self):157 body = self.client.create_floatingip(158 floating_network_id=self.ext_net_id,159 port_id=self.ports[1]['id'],160 fixed_ip_address=self.ports[1]['fixed_ips'][0]['ip_address'])161 created_floating_ip = body['floatingip']162 self.addCleanup(self.client.delete_floatingip,163 created_floating_ip['id'])164 self.assertIsNotNone(created_floating_ip['id'])165 self.assertEqual(created_floating_ip['fixed_ip_address'],166 self.ports[1]['fixed_ips'][0]['ip_address'])167 floating_ip = self.client.update_floatingip(168 created_floating_ip['id'],169 port_id=None)170 self.assertIsNone(floating_ip['floatingip']['port_id'])171 @test.attr(type='smoke')172 def test_create_update_floatingip_with_port_multiple_ip_address(self):173 # Find out ips that can be used for tests174 ips = list(netaddr.IPNetwork(self.subnet['cidr']))175 list_ips = [str(ip) for ip in ips[-3:-1]]176 fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]177 # Create port178 body = self.client.create_port(network_id=self.network['id'],179 fixed_ips=fixed_ips)180 port = body['port']181 self.addCleanup(self.client.delete_port, port['id'])182 # Create floating ip183 body = self.client.create_floatingip(184 floating_network_id=self.ext_net_id,185 port_id=port['id'],186 fixed_ip_address=list_ips[0])187 floating_ip = body['floatingip']188 self.addCleanup(self.client.delete_floatingip, floating_ip['id'])189 self.assertIsNotNone(floating_ip['id'])190 self.assertEqual(floating_ip['fixed_ip_address'], list_ips[0])191 # Update floating ip192 body = self.client.update_floatingip(floating_ip['id'],193 port_id=port['id'],194 fixed_ip_address=list_ips[1])195 update_floating_ip = body['floatingip']196 self.assertEqual(update_floating_ip['fixed_ip_address'],...

Full Screen

Full Screen

test_plugin.py

Source:test_plugin.py Github

copy

Full Screen

...41 @patch('neutron.db.l3_db.L3_NAT_db_mixin.update_floatingip')42 @patch('networking_nec.nwa.l3_plugin.NECNWAL3Plugin._delete_nat')43 @patch('neutron.services.l3_router.l3_router_plugin.'44 'L3RouterPlugin.update_floatingip')45 def _test_update_floatingip(self, ufip, ndn, nsn):46 floatingip = {47 'floatingip': {48 'port_id': None49 }50 }51 fid = 'uuid-fid-100'52 ufip.return_value = 053 self.context.session.query().filter_by().one.return_value = \54 self.floating55 rc = self.plg.update_floatingip(self.context, fid, floatingip)56 self.assertEqual(rc, 0)57 floatingip = {58 'floatingip': {59 'port_id': 'uuid-port_id-101'60 }61 }62 rc = self.plg.update_floatingip(self.context, fid, floatingip)63 self.assertEqual(rc, 0)64 floatingip = {65 'floatingip': {66 'port_id1': 'uuid-port_id-102'67 }68 }69 rc = self.plg.update_floatingip(self.context, fid, floatingip)70 self.assertEqual(rc, 0)71 def test_update_floatingip_raise_before_super_call(self):72 floatingip = {73 'floatingip': {74 'port_id': None75 }76 }77 fid = 'uuid-fid-111'78 self.context.session.query().filter_by().one.side_effect = \79 sa_exc.NoResultFound80 self.assertRaises(81 n_exc.PortNotFound,82 self.plg.update_floatingip, self.context, fid, floatingip83 )...

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 tempest 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