How to use clear_validation_resources method in tempest

Best Python code snippet using tempest_python

test_validation_resources.py

Source:test_validation_resources.py Github

copy

Full Screen

...172 FIP_CLIENT % ('network', 'delete_floatingip'), autospec=True))173 self.os = clients.ServiceClients(174 fake_credentials.FakeKeystoneV3Credentials(), 'fake_uri')175 def test_clear_validation_resources_nova_net(self):176 vr.clear_validation_resources(177 self.os,178 floating_ip=FAKE_FIP_NOVA_NET['floating_ip'],179 security_group=FAKE_SECURITY_GROUP['security_group'],180 keypair=FAKE_KEYPAIR['keypair'],181 use_neutron=False)182 self.assertGreater(self.mock_kp.mock.call_count, 0)183 for call in self.mock_kp.mock.call_args_list[1:]:184 self.assertIn(FAKE_KEYPAIR['keypair']['name'], call[1].values())185 self.assertGreater(self.mock_sg_compute.mock.call_count, 0)186 for call in self.mock_sg_compute.mock.call_args_list[1:]:187 self.assertIn(FAKE_SECURITY_GROUP['security_group']['id'],188 call[1].values())189 self.assertGreater(self.mock_sg_wait_compute.mock.call_count, 0)190 for call in self.mock_sg_wait_compute.mock.call_args_list[1:]:191 self.assertIn(FAKE_SECURITY_GROUP['security_group']['id'],192 call[1].values())193 self.assertEqual(self.mock_sg_network.mock.call_count, 0)194 self.assertEqual(self.mock_sg_wait_network.mock.call_count, 0)195 self.assertGreater(self.mock_fip_compute.mock.call_count, 0)196 for call in self.mock_fip_compute.mock.call_args_list[1:]:197 self.assertIn(FAKE_FIP_NOVA_NET['floating_ip']['id'],198 call[1].values())199 self.assertEqual(self.mock_fip_network.mock.call_count, 0)200 def test_clear_validation_resources_neutron(self):201 vr.clear_validation_resources(202 self.os,203 floating_ip=FAKE_FIP_NEUTRON['floatingip'],204 security_group=FAKE_SECURITY_GROUP['security_group'],205 keypair=FAKE_KEYPAIR['keypair'],206 use_neutron=True)207 self.assertGreater(self.mock_kp.mock.call_count, 0)208 for call in self.mock_kp.mock.call_args_list[1:]:209 self.assertIn(FAKE_KEYPAIR['keypair']['name'], call[1].values())210 self.assertGreater(self.mock_sg_network.mock.call_count, 0)211 for call in self.mock_sg_network.mock.call_args_list[1:]:212 self.assertIn(FAKE_SECURITY_GROUP['security_group']['id'],213 call[1].values())214 self.assertGreater(self.mock_sg_wait_network.mock.call_count, 0)215 for call in self.mock_sg_wait_network.mock.call_args_list[1:]:216 self.assertIn(FAKE_SECURITY_GROUP['security_group']['id'],217 call[1].values())218 self.assertEqual(self.mock_sg_compute.mock.call_count, 0)219 self.assertEqual(self.mock_sg_wait_compute.mock.call_count, 0)220 self.assertGreater(self.mock_fip_network.mock.call_count, 0)221 for call in self.mock_fip_network.mock.call_args_list[1:]:222 self.assertIn(FAKE_FIP_NEUTRON['floatingip']['id'],223 call[1].values())224 self.assertEqual(self.mock_fip_compute.mock.call_count, 0)225 def test_clear_validation_resources_exceptions(self):226 # Test that even with exceptions all cleanups are invoked and that only227 # the first exception is reported.228 # NOTE(andreaf) There's not way of knowing which exception is going to229 # be raised first unless we enforce which resource is cleared first,230 # which is not really interesting, but also not harmful. keypair first.231 self.mock_kp.mock.side_effect = Exception('keypair exception')232 self.mock_sg_network.mock.side_effect = Exception('sg exception')233 self.mock_fip_network.mock.side_effect = Exception('fip exception')234 with testtools.ExpectedException(Exception, value_re='keypair'):235 vr.clear_validation_resources(236 self.os,237 floating_ip=FAKE_FIP_NEUTRON['floatingip'],238 security_group=FAKE_SECURITY_GROUP['security_group'],239 keypair=FAKE_KEYPAIR['keypair'],240 use_neutron=True)241 # Clients calls are still made, but not the wait call242 self.assertGreater(self.mock_kp.mock.call_count, 0)243 self.assertGreater(self.mock_sg_network.mock.call_count, 0)244 self.assertGreater(self.mock_fip_network.mock.call_count, 0)245 def test_clear_validation_resources_wait_not_found_wait(self):246 # Test that a not found on wait is not an exception247 self.mock_sg_wait_network.mock.side_effect = lib_exc.NotFound('yay')248 vr.clear_validation_resources(249 self.os,250 floating_ip=FAKE_FIP_NEUTRON['floatingip'],251 security_group=FAKE_SECURITY_GROUP['security_group'],252 keypair=FAKE_KEYPAIR['keypair'],253 use_neutron=True)254 # Clients calls are still made, but not the wait call255 self.assertGreater(self.mock_kp.mock.call_count, 0)256 self.assertGreater(self.mock_sg_network.mock.call_count, 0)257 self.assertGreater(self.mock_sg_wait_network.mock.call_count, 0)258 self.assertGreater(self.mock_fip_network.mock.call_count, 0)259 def test_clear_validation_resources_wait_not_found_delete(self):260 # Test that a not found on delete is not an exception261 self.mock_kp.mock.side_effect = lib_exc.NotFound('yay')262 self.mock_sg_network.mock.side_effect = lib_exc.NotFound('yay')263 self.mock_fip_network.mock.side_effect = lib_exc.NotFound('yay')264 vr.clear_validation_resources(265 self.os,266 floating_ip=FAKE_FIP_NEUTRON['floatingip'],267 security_group=FAKE_SECURITY_GROUP['security_group'],268 keypair=FAKE_KEYPAIR['keypair'],269 use_neutron=True)270 # Clients calls are still made, but not the wait call271 self.assertGreater(self.mock_kp.mock.call_count, 0)272 self.assertGreater(self.mock_sg_network.mock.call_count, 0)273 self.assertEqual(self.mock_sg_wait_network.mock.call_count, 0)274 self.assertGreater(self.mock_fip_network.mock.call_count, 0)275class TestValidationResourcesFixture(base.TestCase):276 @mock.patch.object(vr, 'create_validation_resources', autospec=True)277 def test_use_fixture(self, mock_vr):278 exp_vr = dict(keypair='keypair',...

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