How to use _update_port_with_address method in tempest

Best Python code snippet using tempest_python

test_allowed_address_pair.py

Source:test_allowed_address_pair.py Github

copy

Full Screen

...54 port = [p for p in ports if p['id'] == port_id]55 msg = 'Created port not found in list of ports returned by Neutron'56 self.assertTrue(port, msg)57 self._confirm_allowed_address_pair(port[0], self.ip_address)58 def _update_port_with_address(self, address, mac_address=None, **kwargs):59 # Create a port without allowed address pair60 body = self.client.create_port(network_id=self.network['id'])61 port_id = body['port']['id']62 self.addCleanup(self.client.delete_port, port_id)63 if mac_address is None:64 mac_address = self.mac_address65 # Update allowed address pair attribute of port66 allowed_address_pairs = [{'ip_address': address,67 'mac_address': mac_address}]68 if kwargs:69 allowed_address_pairs.append(kwargs['allowed_address_pairs'])70 body = self.client.update_port(71 port_id, allowed_address_pairs=allowed_address_pairs)72 allowed_address_pair = body['port']['allowed_address_pairs']73 self.assertItemsEqual(allowed_address_pair, allowed_address_pairs)74 @test.idempotent_id('9599b337-272c-47fd-b3cf-509414414ac4')75 def test_update_port_with_address_pair(self):76 # Update port with allowed address pair77 self._update_port_with_address(self.ip_address)78 @test.idempotent_id('4d6d178f-34f6-4bff-a01c-0a2f8fe909e4')79 def test_update_port_with_cidr_address_pair(self):80 # Update allowed address pair with cidr81 cidr = str(82 netaddr.IPNetwork(config.safe_get_config_value(83 'network', 'project_network_cidr')))84 self._update_port_with_address(cidr)85 @test.idempotent_id('b3f20091-6cd5-472b-8487-3516137df933')86 def test_update_port_with_multiple_ip_mac_address_pair(self):87 # Create an ip _address and mac_address through port create88 resp = self.client.create_port(network_id=self.network['id'])89 newportid = resp['port']['id']90 self.addCleanup(self.client.delete_port, newportid)91 ipaddress = resp['port']['fixed_ips'][0]['ip_address']92 macaddress = resp['port']['mac_address']93 # Update allowed address pair port with multiple ip and mac94 allowed_address_pairs = {'ip_address': ipaddress,95 'mac_address': macaddress}96 self._update_port_with_address(97 self.ip_address, self.mac_address,98 allowed_address_pairs=allowed_address_pairs)99 def _confirm_allowed_address_pair(self, port, ip):100 msg = 'Port allowed address pairs should not be empty'101 self.assertTrue(port['allowed_address_pairs'], msg)102 ip_address = port['allowed_address_pairs'][0]['ip_address']103 mac_address = port['allowed_address_pairs'][0]['mac_address']104 self.assertEqual(ip_address, ip)105 self.assertEqual(mac_address, self.mac_address)106class AllowedAddressPairIpV6TestJSON(AllowedAddressPairTestJSON):...

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