Best Python code snippet using tempest_python
test_floating_ips_rbac.py
Source: test_floating_ips_rbac.py
...37 # cleanup by base class38 cls.networks_client.update_network(cls.fip_extnet_id,39 **{'router:external': False})40 super(FloatingIpsRbacTest, cls).resource_cleanup()41 def _create_floatingip(self, floating_ip_address=None):42 if floating_ip_address is not None:43 body = self.floating_ips_client.create_floatingip(44 floating_network_id=self.fip_extnet_id,45 floating_ip_address=floating_ip_address)46 else:47 body = self.floating_ips_client.create_floatingip(48 floating_network_id=self.fip_extnet_id)49 floating_ip = body['floatingip']50 self.addCleanup(test_utils.call_and_ignore_notfound_exc,51 self.floating_ips_client.delete_floatingip,52 floating_ip['id'])53 return floating_ip54 @rbac_rule_validation.action(service="neutron",55 rule="create_floatingip")56 @decorators.idempotent_id('f8f7474c-b8a5-4174-af84-73097d6ced38')57 def test_create_floating_ip(self):58 """Create floating IP.59 RBAC test for the neutron create_floatingip policy60 """61 self.rbac_utils.switch_role(self, toggle_rbac_role=True)62 self._create_floatingip()63 @rbac_rule_validation.action(service="neutron",64 rule="create_floatingip:floating_ip_address")65 @decorators.idempotent_id('a8bb826a-403d-4130-a55d-120a0a660806')66 def test_create_floating_ip_floatingip_address(self):67 """Create floating IP with address.68 RBAC test for the neutron create_floatingip:floating_ip_address policy69 """70 fip = str(netaddr.IPAddress(self.cidr) + 10)71 self.rbac_utils.switch_role(self, toggle_rbac_role=True)72 self._create_floatingip(floating_ip_address=fip)73 @rbac_rule_validation.action(service="neutron",74 rule="update_floatingip")75 @decorators.idempotent_id('2ab1b060-19f8-4ef6-a838-e2ab7b377c63')76 def test_update_floating_ip(self):77 """Update floating IP.78 RBAC test for the neutron update_floatingip policy79 """80 floating_ip = self._create_floatingip()81 self.rbac_utils.switch_role(self, toggle_rbac_role=True)82 # Associate floating IP to the other port83 self.floating_ips_client.update_floatingip(84 floating_ip['id'], port_id=None)85 @rbac_rule_validation.action(service="neutron",86 rule="get_floatingip",87 expected_error_code=404)88 @decorators.idempotent_id('f8846fd0-c976-48fe-a148-105303931b32')89 def test_show_floating_ip(self):90 """Show floating IP.91 RBAC test for the neutron get_floatingip policy92 """93 floating_ip = self._create_floatingip()94 self.rbac_utils.switch_role(self, toggle_rbac_role=True)95 # Show floating IP96 self.floating_ips_client.show_floatingip(floating_ip['id'])97 @rbac_rule_validation.action(service="neutron",98 rule="delete_floatingip",99 expected_error_code=404)100 @decorators.idempotent_id('2611b068-30d4-4241-a78f-1b801a14db7e')101 def test_delete_floating_ip(self):102 """Delete floating IP.103 RBAC test for the neutron delete_floatingip policy104 """105 floating_ip = self._create_floatingip()106 self.rbac_utils.switch_role(self, toggle_rbac_role=True)107 # Delete the floating IP...
test_floating_ip.py
Source: test_floating_ip.py
1import os2import unittest3import mock4from cloudify.test_utils import workflow_test5from cloudify.mocks import MockNodeInstanceContext6from neutron_plugin.floatingip import (7 FLOATINGIP_OPENSTACK_TYPE, FLOATING_NETWORK_ERROR_PREFIX)8from openstack_plugin_common import OPENSTACK_ID_PROPERTY9class FloatingIPTest(unittest.TestCase):10 @mock.patch('neutron_plugin.network.create')11 @mock.patch('neutronclient.v2_0.client.Client.create_floatingip')12 @workflow_test(os.path.join('resources', 'test_fip_rel.yaml'),13 copy_plugin_yaml=True)14 def test_network_rel(self, cfy_local, *_):15 def _mock_rel(*_):16 return MockNodeInstanceContext(runtime_properties={17 OPENSTACK_ID_PROPERTY: 'my-id'18 })19 def _mock_create(_, fip):20 self.assertEqual(fip[FLOATINGIP_OPENSTACK_TYPE][21 'floating_network_id'], 'my-id')22 return {FLOATINGIP_OPENSTACK_TYPE: {23 'id': '1234',24 'floating_ip_address': '1.2.3.4'25 }}26 with mock.patch('neutronclient.v2_0.client.Client.create_floatingip',27 new=_mock_create):28 with mock.patch(29 'neutron_plugin.floatingip.get_single_connected_node_by_'30 'openstack_type', new=_mock_rel):31 cfy_local.execute('install')32 @mock.patch('neutron_plugin.network.create')33 @mock.patch('neutronclient.v2_0.client.Client.create_floatingip')34 @workflow_test(os.path.join('resources', 'test_fip_rel_and_id.yaml'),35 copy_plugin_yaml=True)36 def test_network_rel_and_id(self, cfy_local, *_):37 def _mock_rel(*_):38 return MockNodeInstanceContext(runtime_properties={39 OPENSTACK_ID_PROPERTY: 'my-id'40 })41 with mock.patch('neutron_plugin.floatingip.get_single_connected_node_'42 'by_openstack_type',43 new=_mock_rel):44 with self.assertRaises(Exception) as ex:45 cfy_local.execute('install')...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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!!