Best Python code snippet using tempest_python
test_snapshots_actions.py
Source:test_snapshots_actions.py
...48 def tearDown(self):49 # Set snapshot's status to available after test50 status = 'available'51 snapshot_id = self.snapshot['id']52 self.admin_snapshots_client.reset_snapshot_status(snapshot_id,53 status)54 super(SnapshotsActionsV2Test, self).tearDown()55 def _create_reset_and_force_delete_temp_snapshot(self, status=None):56 # Create snapshot, reset snapshot status,57 # and force delete temp snapshot58 temp_snapshot = self.create_snapshot(self.volume['id'])59 if status:60 _, body = self.admin_snapshots_client.\61 reset_snapshot_status(temp_snapshot['id'], status)62 _, volume_delete = self.admin_snapshots_client.\63 force_delete_snapshot(temp_snapshot['id'])64 self.client.wait_for_resource_deletion(temp_snapshot['id'])65 def _get_progress_alias(self):66 return 'os-extended-snapshot-attributes:progress'67 @test.attr(type='gate')68 def test_reset_snapshot_status(self):69 # Reset snapshot status to creating70 status = 'creating'71 _, body = self.admin_snapshots_client.\72 reset_snapshot_status(self.snapshot['id'], status)73 _, snapshot_get \74 = self.admin_snapshots_client.get_snapshot(self.snapshot['id'])75 self.assertEqual(status, snapshot_get['status'])76 @test.attr(type='gate')77 def test_update_snapshot_status(self):78 # Reset snapshot status to creating79 status = 'creating'80 self.admin_snapshots_client.\81 reset_snapshot_status(self.snapshot['id'], status)82 # Update snapshot status to error83 progress = '80%'84 status = 'error'85 progress_alias = self._get_progress_alias()86 _, body = self.client.update_snapshot_status(self.snapshot['id'],87 status, progress)88 _, snapshot_get \89 = self.admin_snapshots_client.get_snapshot(self.snapshot['id'])90 self.assertEqual(status, snapshot_get['status'])91 self.assertEqual(progress, snapshot_get[progress_alias])92 @test.attr(type='gate')93 def test_snapshot_force_delete_when_snapshot_is_creating(self):94 # test force delete when status of snapshot is creating95 self._create_reset_and_force_delete_temp_snapshot('creating')...
test_volume_snapshots_actions.py
Source:test_volume_snapshots_actions.py
...37 def tearDown(self):38 # Set snapshot's status to available after test39 status = 'available'40 snapshot_id = self.snapshot['id']41 self.admin_snapshots_client.reset_snapshot_status(snapshot_id,42 status)43 super(SnapshotsActionsV2Test, self).tearDown()44 def _create_reset_and_force_delete_temp_snapshot(self, status=None):45 # Create snapshot, reset snapshot status,46 # and force delete temp snapshot47 temp_snapshot = self.create_snapshot(volume_id=self.volume['id'])48 if status:49 self.admin_snapshots_client.\50 reset_snapshot_status(temp_snapshot['id'], status)51 self.admin_snapshots_client.\52 force_delete_snapshot(temp_snapshot['id'])53 self.client.wait_for_resource_deletion(temp_snapshot['id'])54 def _get_progress_alias(self):55 return 'os-extended-snapshot-attributes:progress'56 @test.idempotent_id('3e13ca2f-48ea-49f3-ae1a-488e9180d535')57 def test_reset_snapshot_status(self):58 # Reset snapshot status to creating59 status = 'creating'60 self.admin_snapshots_client.\61 reset_snapshot_status(self.snapshot['id'], status)62 snapshot_get = self.admin_snapshots_client.show_snapshot(63 self.snapshot['id'])['snapshot']64 self.assertEqual(status, snapshot_get['status'])65 @test.idempotent_id('41288afd-d463-485e-8f6e-4eea159413eb')66 def test_update_snapshot_status(self):67 # Reset snapshot status to creating68 status = 'creating'69 self.admin_snapshots_client.\70 reset_snapshot_status(self.snapshot['id'], status)71 # Update snapshot status to error72 progress = '80%'73 status = 'error'74 progress_alias = self._get_progress_alias()75 self.client.update_snapshot_status(self.snapshot['id'],76 status=status, progress=progress)77 snapshot_get = self.admin_snapshots_client.show_snapshot(78 self.snapshot['id'])['snapshot']79 self.assertEqual(status, snapshot_get['status'])80 self.assertEqual(progress, snapshot_get[progress_alias])81 @test.idempotent_id('05f711b6-e629-4895-8103-7ca069f2073a')82 def test_snapshot_force_delete_when_snapshot_is_creating(self):83 # test force delete when status of snapshot is creating84 self._create_reset_and_force_delete_temp_snapshot('creating')...
test_snapshots_actions_rbac.py
Source:test_snapshots_actions_rbac.py
...32 cls.snapshot_id = cls.snapshot['id']33 def tearDown(self):34 # Set snapshot's status to available after test35 status = 'available'36 self.snapshots_client.reset_snapshot_status(self.snapshot_id,37 status)38 waiters.wait_for_volume_resource_status(self.snapshots_client,39 self.snapshot_id, status)40 super(SnapshotsActionsV3RbacTest, self).tearDown()41 @rbac_rule_validation.action(42 service="cinder",43 rules=["volume_extension:snapshot_admin_actions:reset_status"])44 @decorators.idempotent_id('ea430145-34ef-408d-b678-95d5ae5f46eb')45 def test_reset_snapshot_status(self):46 status = 'error'47 with self.override_role():48 self.snapshots_client.reset_snapshot_status(49 self.snapshot['id'], status)50 waiters.wait_for_volume_resource_status(51 self.snapshots_client, self.snapshot['id'], status)52 @rbac_rule_validation.action(53 service="cinder",54 rules=["volume_extension:snapshot_admin_actions:force_delete"])55 @decorators.idempotent_id('a8b0f7d8-4c00-4645-b8d5-33ab4eecc6cb')56 def test_snapshot_force_delete(self):57 temp_snapshot = self.create_snapshot(self.volume['id'])58 with self.override_role():59 self.snapshots_client.force_delete_snapshot(temp_snapshot['id'])60 self.snapshots_client.wait_for_resource_deletion(temp_snapshot['id'])61 @decorators.idempotent_id('a95eab2a-c441-4609-9235-f7478627da88')62 @rbac_rule_validation.action(63 service="cinder",64 rules=["snapshot_extension:snapshot_actions:update_snapshot_status"])65 def test_update_snapshot_status(self):66 status = 'creating'67 self.snapshots_client.reset_snapshot_status(68 self.snapshot['id'], status)69 waiters.wait_for_volume_resource_status(self.snapshots_client,70 self.snapshot['id'], status)71 with self.override_role():72 self.snapshots_client.update_snapshot_status(self.snapshot['id'],73 status="creating")74 waiters.wait_for_volume_resource_status(...
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!!