Best Python code snippet using tempest_python
test_disk_config.py
Source:test_disk_config.py
...27 super(ServerDiskConfigTestJSON, cls).setUpClass()28 cls.client = cls.os.servers_client29 resp, server = cls.create_test_server(wait_until='ACTIVE')30 cls.server_id = server['id']31 def _update_server_with_disk_config(self, disk_config):32 resp, server = self.client.get_server(self.server_id)33 if disk_config != server['OS-DCF:diskConfig']:34 resp, server = self.client.update_server(self.server_id,35 disk_config=disk_config)36 self.assertEqual(200, resp.status)37 self.client.wait_for_server_status(server['id'], 'ACTIVE')38 resp, server = self.client.get_server(server['id'])39 self.assertEqual(disk_config, server['OS-DCF:diskConfig'])40 @attr(type='gate')41 def test_rebuild_server_with_manual_disk_config(self):42 # A server should be rebuilt using the manual disk config option43 self._update_server_with_disk_config(disk_config='AUTO')44 resp, server = self.client.rebuild(self.server_id,45 self.image_ref_alt,46 disk_config='MANUAL')47 # Wait for the server to become active48 self.client.wait_for_server_status(server['id'], 'ACTIVE')49 # Verify the specified attributes are set correctly50 resp, server = self.client.get_server(server['id'])51 self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])52 @attr(type='gate')53 def test_rebuild_server_with_auto_disk_config(self):54 # A server should be rebuilt using the auto disk config option55 self._update_server_with_disk_config(disk_config='MANUAL')56 resp, server = self.client.rebuild(self.server_id,57 self.image_ref_alt,58 disk_config='AUTO')59 # Wait for the server to become active60 self.client.wait_for_server_status(server['id'], 'ACTIVE')61 # Verify the specified attributes are set correctly62 resp, server = self.client.get_server(server['id'])63 self.assertEqual('AUTO', server['OS-DCF:diskConfig'])64 def _get_alternative_flavor(self):65 resp, server = self.client.get_server(self.server_id)66 if server['flavor']['id'] == self.flavor_ref:67 return self.flavor_ref_alt68 else:69 return self.flavor_ref70 @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')71 @attr(type='gate')72 def test_resize_server_from_manual_to_auto(self):73 # A server should be resized from manual to auto disk config74 self._update_server_with_disk_config(disk_config='MANUAL')75 # Resize with auto option76 flavor_id = self._get_alternative_flavor()77 self.client.resize(self.server_id, flavor_id, disk_config='AUTO')78 self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')79 self.client.confirm_resize(self.server_id)80 self.client.wait_for_server_status(self.server_id, 'ACTIVE')81 resp, server = self.client.get_server(self.server_id)82 self.assertEqual('AUTO', server['OS-DCF:diskConfig'])83 @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')84 @attr(type='gate')85 def test_resize_server_from_auto_to_manual(self):86 # A server should be resized from auto to manual disk config87 self._update_server_with_disk_config(disk_config='AUTO')88 # Resize with manual option89 flavor_id = self._get_alternative_flavor()90 self.client.resize(self.server_id, flavor_id, disk_config='MANUAL')91 self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')92 self.client.confirm_resize(self.server_id)93 self.client.wait_for_server_status(self.server_id, 'ACTIVE')94 resp, server = self.client.get_server(self.server_id)95 self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])96 @attr(type='gate')97 def test_update_server_from_auto_to_manual(self):98 # A server should be updated from auto to manual disk config99 self._update_server_with_disk_config(disk_config='AUTO')100 # Update the disk_config attribute to manual101 resp, server = self.client.update_server(self.server_id,102 disk_config='MANUAL')103 self.assertEqual(200, resp.status)104 self.client.wait_for_server_status(server['id'], 'ACTIVE')105 # Verify the disk_config attribute is set correctly106 resp, server = self.client.get_server(server['id'])107 self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])108class ServerDiskConfigTestXML(ServerDiskConfigTestJSON):...
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!!