How to use _volume_create_get_update_delete method in tempest

Best Python code snippet using tempest_python

test_volumes_get.py

Source:test_volumes_get.py Github

copy

Full Screen

...30 cls.descrip_field = cls.special_fields['descrip_field']31 def _delete_volume(self, volume_id):32 self.client.delete_volume(volume_id)33 self.client.wait_for_resource_deletion(volume_id)34 def _volume_create_get_update_delete(self, **kwargs):35 # Create a volume, Get it's details and Delete the volume36 volume = {}37 v_name = data_utils.rand_name('Volume')38 metadata = {'Type': 'Test'}39 # Create a volume40 kwargs[self.name_field] = v_name41 kwargs['metadata'] = metadata42 volume = self.client.create_volume(**kwargs)43 self.assertIn('id', volume)44 self.addCleanup(self._delete_volume, volume['id'])45 self.client.wait_for_volume_status(volume['id'], 'available')46 self.assertIn(self.name_field, volume)47 self.assertEqual(volume[self.name_field], v_name,48 "The created volume name is not equal "49 "to the requested name")50 self.assertTrue(volume['id'] is not None,51 "Field volume id is empty or not found.")52 # Get Volume information53 fetched_volume = self.client.show_volume(volume['id'])54 self.assertEqual(v_name,55 fetched_volume[self.name_field],56 'The fetched Volume name is different '57 'from the created Volume')58 self.assertEqual(volume['id'],59 fetched_volume['id'],60 'The fetched Volume id is different '61 'from the created Volume')62 self.assertThat(fetched_volume['metadata'].items(),63 matchers.ContainsAll(metadata.items()),64 'The fetched Volume metadata misses data '65 'from the created Volume')66 if 'imageRef' in kwargs:67 self.assertEqual('true', fetched_volume['bootable'])68 if 'imageRef' not in kwargs:69 self.assertEqual('false', fetched_volume['bootable'])70 # Update Volume71 # Test volume update when display_name is same with original value72 params = {self.name_field: v_name}73 self.client.update_volume(volume['id'], **params)74 # Test volume update when display_name is new75 new_v_name = data_utils.rand_name('new-Volume')76 new_desc = 'This is the new description of volume'77 params = {self.name_field: new_v_name,78 self.descrip_field: new_desc}79 update_volume = self.client.update_volume(volume['id'], **params)80 # Assert response body for update_volume method81 self.assertEqual(new_v_name, update_volume[self.name_field])82 self.assertEqual(new_desc, update_volume[self.descrip_field])83 # Assert response body for show_volume method84 updated_volume = self.client.show_volume(volume['id'])85 self.assertEqual(volume['id'], updated_volume['id'])86 self.assertEqual(new_v_name, updated_volume[self.name_field])87 self.assertEqual(new_desc, updated_volume[self.descrip_field])88 self.assertThat(updated_volume['metadata'].items(),89 matchers.ContainsAll(metadata.items()),90 'The fetched Volume metadata misses data '91 'from the created Volume')92 # Test volume create when display_name is none and display_description93 # contains specific characters,94 # then test volume update if display_name is duplicated95 new_volume = {}96 new_v_desc = data_utils.rand_name('@#$%^* description')97 params = {self.descrip_field: new_v_desc,98 'availability_zone': volume['availability_zone']}99 new_volume = self.client.create_volume(**params)100 self.assertIn('id', new_volume)101 self.addCleanup(self._delete_volume, new_volume['id'])102 self.client.wait_for_volume_status(new_volume['id'], 'available')103 params = {self.name_field: volume[self.name_field],104 self.descrip_field: volume[self.descrip_field]}105 self.client.update_volume(new_volume['id'], **params)106 if 'imageRef' in kwargs:107 self.assertEqual('true', updated_volume['bootable'])108 if 'imageRef' not in kwargs:109 self.assertEqual('false', updated_volume['bootable'])110 @test.attr(type='smoke')111 @test.idempotent_id('27fb0e9f-fb64-41dd-8bdb-1ffa762f0d51')112 def test_volume_create_get_update_delete(self):113 self._volume_create_get_update_delete()114 @test.attr(type='smoke')115 @test.idempotent_id('54a01030-c7fc-447c-86ee-c1182beae638')116 @test.services('image')117 def test_volume_create_get_update_delete_from_image(self):118 self._volume_create_get_update_delete(imageRef=CONF.compute.image_ref)119 @test.idempotent_id('3f591b4a-7dc6-444c-bd51-77469506b3a1')120 def test_volume_create_get_update_delete_as_clone(self):121 origin = self.create_volume()122 self._volume_create_get_update_delete(source_volid=origin['id'])123class VolumesV1GetTest(VolumesV2GetTest):...

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