Best Python code snippet using tempest_python
test_dhcp_ipv6.py
Source:test_dhcp_ipv6.py
...33 @classmethod34 def resource_setup(cls):35 super(NetworksTestDHCPv6, cls).resource_setup()36 cls.network = cls.create_network()37 def _remove_from_list_by_index(self, things_list, elem):38 for index, i in enumerate(things_list):39 if i['id'] == elem['id']:40 break41 del things_list[index]42 def _clean_network(self):43 body = self.client.list_ports()44 ports = body['ports']45 for port in ports:46 if (port['device_owner'].startswith(47 constants.DEVICE_OWNER_ROUTER_INTF)48 and port['device_id'] in [r['id'] for r in self.routers]):49 self.client.remove_router_interface_with_port_id(50 port['device_id'], port['id']51 )52 else:53 if port['id'] in [p['id'] for p in self.ports]:54 self.client.delete_port(port['id'])55 self._remove_from_list_by_index(self.ports, port)56 body = self.client.list_subnets()57 subnets = body['subnets']58 for subnet in subnets:59 if subnet['id'] in [s['id'] for s in self.subnets]:60 self.client.delete_subnet(subnet['id'])61 self._remove_from_list_by_index(self.subnets, subnet)62 body = self.client.list_routers()63 routers = body['routers']64 for router in routers:65 if router['id'] in [r['id'] for r in self.routers]:66 self.client.delete_router(router['id'])67 self._remove_from_list_by_index(self.routers, router)68 @test.idempotent_id('98244d88-d990-4570-91d4-6b25d70d08af')69 def test_dhcp_stateful_fixedips_outrange(self):70 """When port gets IP address from fixed IP range it71 shall be checked if it's from subnets range.72 """73 kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',74 'ipv6_address_mode': 'dhcpv6-stateful'}75 subnet = self.create_subnet(self.network, **kwargs)76 ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],77 subnet["allocation_pools"][0]["end"])78 for i in range(1, 3):79 ip = netaddr.IPAddress(ip_range.last + i).format()80 self.assertRaises(lib_exc.BadRequest,81 self.create_port,...
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!!