Best Python code snippet using tempest_python
test_images_oneserver.py
Source:test_images_oneserver.py
...33 @classmethod34 def setup_clients(cls):35 super(ImagesOneServerTestJSON, cls).setup_clients()36 cls.client = cls.compute_images_client37 def _get_default_flavor_disk_size(self, flavor_id):38 flavor = self.flavors_client.show_flavor(flavor_id)['flavor']39 return flavor['disk']40 @decorators.idempotent_id('3731d080-d4c5-4872-b41a-64d0d0021314')41 def test_create_delete_image(self):42 server_id = self.create_test_server(wait_until='ACTIVE')['id']43 # Create a new image44 name = data_utils.rand_name('image')45 meta = {'image_type': 'test'}46 body = self.client.create_image(server_id, name=name,47 metadata=meta)48 image_id = data_utils.parse_image_id(body.response['location'])49 self.addCleanup(test_utils.call_and_ignore_notfound_exc,50 self.client.delete_image, image_id)51 waiters.wait_for_image_status(self.client, image_id, 'ACTIVE')52 # Verify the image was created correctly53 image = self.client.show_image(image_id)['image']54 self.assertEqual(name, image['name'])55 self.assertEqual('test', image['metadata']['image_type'])56 original_image = self.client.show_image(self.image_ref)['image']57 # Verify minRAM is the same as the original image58 self.assertEqual(image['minRam'], original_image['minRam'])59 # Verify minDisk is the same as the original image or the flavor size60 flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)61 self.assertIn(str(image['minDisk']),62 (str(original_image['minDisk']), str(flavor_disk_size)))63 # Verify the image was deleted correctly64 self.client.delete_image(image_id)65 self.client.wait_for_resource_deletion(image_id)66 @decorators.idempotent_id('3b7c6fe4-dfe7-477c-9243-b06359db51e6')67 def test_create_image_specify_multibyte_character_image_name(self):68 server_id = self.create_test_server(wait_until='ACTIVE')['id']69 # prefix character is:70 # http://www.fileformat.info/info/unicode/char/1F4A9/index.htm71 # We use a string with 3 byte utf-8 character due to bug72 # #1370954 in glance which will 500 if mysql is used as the73 # backend and it attempts to store a 4 byte utf-8 character74 utf8_name = data_utils.rand_name(b'\xe2\x82\xa1'.decode('utf-8'))...
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!!