Best Python code snippet using tempest_python
snapshots_client.py
Source:snapshots_client.py
...167 resp, body = self.delete(url)168 self.validate_response(169 schema.delete_snapshot_metadata_item, resp, body)170 return rest_client.ResponseBody(resp, body)171 def force_delete_snapshot(self, snapshot_id):172 """Force Delete Snapshot."""173 post_body = json.dumps({'os-force_delete': {}})174 resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)175 self.validate_response(schema.force_delete_snapshot, resp, body)176 return rest_client.ResponseBody(resp, body)177 def unmanage_snapshot(self, snapshot_id):178 """Unmanage a snapshot."""179 post_body = json.dumps({'os-unmanage': {}})180 url = 'snapshots/%s/action' % (snapshot_id)181 resp, body = self.post(url, post_body)182 self.validate_response(schema.unmanage_snapshot, resp, body)...
template_test.py
Source:template_test.py
1"""Test variou executions of the cookiecutter2Each parametrize test case is a set of cookiecutter json overrides3"""4import logging5import os6import pytest7import testinfra # pylint: disable=W06118from cookiecutter.main import cookiecutter9logging.basicConfig(level=logging.DEBUG)10log = logging.getLogger()11PROJECT_DIR = os.getcwd()12@pytest.mark.parametrize(13 "ccinput",14 [15 (16 {17 "role_name": "fff",18 "vpc_id": "vpc-fff",19 "subnet_id": "subnet-fff",20 "ami_id": "ami-fff"21 }),22 (23 {24 "role_name": "ggg",25 "vpc_id": "vpc-ggg",26 "subnet_id": "subnet-ggg",27 "ami_id": "ami-ggg"28 }),29 ],30)31class TestClass: # pylint: disable=R090332 """Table test the cookiecutter options"""33 def test_(34 self, host, tmp_path, ccinput35 ): # pylint: disable=R020136 """Iterate on different cookiecutter json overrides"""37 role_dir=str(tmp_path) + "/" + "arole-" + ccinput["role_name"]38 os.chdir(tmp_path)39 log.info("tmpdir: %s", str(tmp_path))40 cookiecutter(41 PROJECT_DIR,42 no_input=True,43 extra_context=ccinput,44 )45 # check packer base template46 packer_base_template = host.file(role_dir + '/packer/base-test-images.pkr.hcl')47 assert packer_base_template.exists48 assert packer_base_template.contains('ansible-test-arole-'+str(ccinput["role_name"]))49 assert packer_base_template.contains(' force_delete_snapshot = true')50 assert packer_base_template.contains(' force_deregister = true')51 # check packer_vars.hcl52 packer_base_vars = host.file(role_dir + '/packer/base-test-vars.hcl')53 assert packer_base_vars.exists54 assert packer_base_vars.contains('# vpc_id = "vpc-abc123"')55 assert packer_base_vars.contains('# subnet_id = "subnet-abc123"')56 # check create_test_vpc.sh57 create_stack_sh = host.file(role_dir + '/scripts/create_test_vpc.sh')58 assert create_stack_sh.exists59 assert create_stack_sh.contains('aws cloudformation create-stack '60 '--stack-name "test-arole-'+str(61 ccinput["role_name"])+'"')62 delete_stack_sh = host.file(role_dir + '/scripts/delete_test_vpc.sh')63 assert delete_stack_sh.exists64 assert delete_stack_sh.contains('aws cloudformation delete-stack '65 '--stack-name "test-arole-'+str(...
test_snapshots_actions_rbac.py
Source:test_snapshots_actions_rbac.py
...44 @decorators.idempotent_id('a8b0f7d8-4c00-4645-b8d5-33ab4eecc6cb')45 def test_snapshot_force_delete(self):46 temp_snapshot = self.create_snapshot(self.volume['id'])47 self.rbac_utils.switch_role(self, toggle_rbac_role=True)48 self.snapshots_client.force_delete_snapshot(temp_snapshot['id'])49 self.snapshots_client.wait_for_resource_deletion(temp_snapshot['id'])50class SnapshotsActionsV3RbacTest(SnapshotsActionsRbacTest):...
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!!