Best Python code snippet using tempest_python
base.py
Source: base.py
...25):26 @classmethod27 def resource_setup(cls):28 super(BaseFlowClassifierTest, cls).resource_setup()29 if not test.is_extension_enabled('flow_classifier', 'network'):30 msg = "FlowClassifier Extension not enabled."31 raise cls.skipException(msg)32 cls.network = cls.create_network()33 cls.subnet = cls.create_subnet(cls.network)34 cls.host_id = socket.gethostname()35 @classmethod36 def resource_cleanup(cls):37 if not test.is_extension_enabled('flow_classifier', 'network'):38 msg = "FlowClassifier Extension not enabled."39 raise cls.skipException(msg)40 super(BaseFlowClassifierTest, cls).resource_cleanup()41 @classmethod42 def _create_port(cls, network, **kwargs):43 body = cls.admin_ports_client.create_port(44 network_id=network['id'],45 **kwargs)46 port = body['port']47 return port48 def _try_create_flowclassifier(self, **kwargs):49 if 'logical_source_port' not in kwargs:50 port_kwargs = {"binding:host_id": self.host_id}51 port = self._create_port(network=self.network, **port_kwargs)52 self.addCleanup(self._try_delete_port, port['id'])53 kwargs['logical_source_port'] = port['id']54 if 'source_ip_prefix' not in kwargs:55 port_ip_prefix = str(netaddr.IPNetwork(56 port['fixed_ips'][0]['ip_address']))57 kwargs['source_ip_prefix'] = port_ip_prefix58 fc = self.create_flowclassifier(**kwargs)59 self.addCleanup(self._try_delete_flowclassifier, fc['id'])60 return fc61 def _try_delete_port(self, port_id):62 try:63 self.admin_ports_client.delete_port(port_id)64 except lib_exc.NotFound:65 pass66 body = self.admin_ports_client.list_ports()67 ports_list = body['ports']68 self.assertNotIn(port_id, [n['id'] for n in ports_list])69 def _try_delete_flowclassifier(self, fc_id):70 # delete flowclassifier, if it exists71 try:72 self.flowclassifier_client.delete_flowclassifier(fc_id)73 # if flowclassifier is not found, this means it was deleted74 except lib_exc.NotFound:75 pass76 body = self.flowclassifier_client.list_flowclassifiers()77 fc_list = body['flow_classifiers']78 self.assertNotIn(fc_id, [n['id'] for n in fc_list])79class BaseSfcTest(80 sfc_client.SfcClientMixin, BaseFlowClassifierTest81):82 @classmethod83 def resource_setup(cls):84 super(BaseSfcTest, cls).resource_setup()85 if not test.is_extension_enabled('sfc', 'network'):86 msg = "Sfc Extension not enabled."87 raise cls.skipException(msg)88 @classmethod89 def resource_cleanup(cls):90 if not test.is_extension_enabled('sfc', 'network'):91 msg = "Sfc Extension not enabled."92 raise cls.skipException(msg)93 super(BaseSfcTest, cls).resource_cleanup()94 def _try_create_port_pair(self, **kwargs):95 if 'ingress' not in kwargs or 'egress' not in 'kwargs':96 router = self.admin_routers_client.create_router(97 name=data_utils.rand_name('router-'))['router']98 self.addCleanup(99 self.admin_routers_client.delete_router, router['id'])100 port_kwargs = {"binding:host_id": self.host_id}101 port = self._create_port(102 network=self.network, **port_kwargs)103 self.addCleanup(self._try_delete_port, port['id'])104 self.admin_routers_client.add_router_interface(...
test_networks.py
Source: test_networks.py
...34 # Verify the details of a network35 body = self.client.show_network(self.network['id'])36 network = body['network']37 fields = ['id', 'name']38 if test.is_extension_enabled('net-mtu', 'network'):39 fields.append('mtu')40 for key in fields:41 self.assertEqual(network[key], self.network[key])42 @test.idempotent_id('867819bb-c4b6-45f7-acf9-90edcf70aa5e')43 def test_show_network_fields(self):44 # Verify specific fields of a network45 fields = ['id', 'name']46 if test.is_extension_enabled('net-mtu', 'network'):47 fields.append('mtu')48 body = self.client.show_network(self.network['id'],49 fields=fields)50 network = body['network']51 self.assertEqual(sorted(network.keys()), sorted(fields))52 for field_name in fields:53 self.assertEqual(network[field_name], self.network[field_name])54 @test.idempotent_id('c72c1c0c-2193-4aca-ccc4-b1442640bbbb')55 @test.requires_ext(extension="standard-attr-description",56 service="network")57 def test_create_update_network_description(self):58 body = self.create_network(description='d1')59 self.assertEqual('d1', body['description'])60 net_id = body['id']61 body = self.client.list_networks(id=net_id)['networks'][0]62 self.assertEqual('d1', body['description'])63 body = self.client.update_network(body['id'],64 description='d2')65 self.assertEqual('d2', body['network']['description'])66 body = self.client.list_networks(id=net_id)['networks'][0]67 self.assertEqual('d2', body['description'])68 @test.idempotent_id('6ae6d24f-9194-4869-9c85-c313cb20e080')69 def test_list_networks_fields(self):70 # Verify specific fields of the networks71 fields = ['id', 'name']72 if test.is_extension_enabled('net-mtu', 'network'):73 fields.append('mtu')74 body = self.client.list_networks(fields=fields)75 networks = body['networks']76 self.assertNotEmpty(networks, "Network list returned is empty")77 for network in networks:78 self.assertEqual(sorted(network.keys()), sorted(fields))79class NetworksSearchCriteriaTest(base.BaseSearchCriteriaTest):80 resource = 'network'81 list_kwargs = {'shared': False}82 @classmethod83 def resource_setup(cls):84 super(NetworksSearchCriteriaTest, cls).resource_setup()85 for name in cls.resource_names:86 cls.create_network(network_name=name)...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
Anyone who has worked in the software industry for a while can tell you stories about projects that were on the verge of failure. Many initiatives fail even before they reach clients, which is especially disheartening when the failure is fully avoidable.
Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!
Joseph, who has been working as a Quality Engineer, was assigned to perform web automation for the company’s website.
Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.
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!!