Best Python code snippet using tempest_python
test_base.py
Source:test_base.py
...30 image_id = uuidutils.generate_uuid()31 fake_image = mock.Mock(response={'location': image_id})32 compute_images_client.create_image.return_value = fake_image33 # call the utility method34 image = compute_base.BaseV2ComputeTest.create_image_from_server(35 mock.sentinel.server_id, name='fake-snapshot-name')36 self.assertEqual(fake_image, image)37 # make our assertions38 compute_images_client.create_image.assert_called_once_with(39 mock.sentinel.server_id, name='fake-snapshot-name')40 self.assertEqual(1, len(compute_base.BaseV2ComputeTest.images))41 self.assertEqual(image_id, compute_base.BaseV2ComputeTest.images[0])42 @mock.patch.multiple(compute_base.BaseV2ComputeTest,43 compute_images_client=mock.DEFAULT,44 images=[], create=True)45 @mock.patch.object(waiters, 'wait_for_image_status')46 def test_create_image_from_server_wait_until_active(self,47 wait_for_image_status,48 compute_images_client):49 """Tests create_image_from_server with wait_until='ACTIVE' kwarg."""50 # setup mocks51 image_id = uuidutils.generate_uuid()52 fake_image = mock.Mock(response={'location': image_id})53 compute_images_client.create_image.return_value = fake_image54 compute_images_client.show_image.return_value = (55 {'image': fake_image})56 # call the utility method57 image = compute_base.BaseV2ComputeTest.create_image_from_server(58 mock.sentinel.server_id, wait_until='ACTIVE')59 self.assertEqual(fake_image, image)60 # make our assertions61 wait_for_image_status.assert_called_once_with(62 compute_images_client, image_id, 'ACTIVE')63 compute_images_client.show_image.assert_called_once_with(image_id)64 @mock.patch.multiple(compute_base.BaseV2ComputeTest,65 compute_images_client=mock.DEFAULT,66 servers_client=mock.DEFAULT,67 images=[], create=True)68 @mock.patch.object(waiters, 'wait_for_image_status',69 side_effect=lib_exc.NotFound)70 def _test_create_image_from_server_wait_until_active_not_found(71 self, wait_for_image_status, compute_images_client,...
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!!