How to use _create_tags_for_each_resource method in tempest

Best Python code snippet using tempest_python

test_tags.py

Source:test_tags.py Github

copy

Full Screen

...110 cls.subnetpool = cls.subnetpools_client.create_subnetpool(111 name=subnetpool_name, prefixes=prefix)['subnetpool']112 cls.addClassResourceCleanup(cls.subnetpools_client.delete_subnetpool,113 cls.subnetpool['id'])114 def _create_tags_for_each_resource(self):115 # Create a tag for each resource in `SUPPORTED_RESOURCES` and return116 # the list of tag names.117 tag_names = []118 for resource in self.SUPPORTED_RESOURCES:119 tag_name = data_utils.rand_name(self.__class__.__name__ + '-Tag')120 tag_names.append(tag_name)121 resource_object = getattr(self, resource[:-1])122 self.tags_client.create_tag(resource, resource_object['id'],123 tag_name)124 self.addCleanup(self.tags_client.delete_all_tags, resource,125 resource_object['id'])126 return tag_names127 @decorators.idempotent_id('c6231efa-9a89-4adf-b050-2a3156b8a1d9')128 def test_create_check_list_and_delete_tags(self):129 tag_names = self._create_tags_for_each_resource()130 for i, resource in enumerate(self.SUPPORTED_RESOURCES):131 # Ensure that a tag was created for each resource.132 resource_object = getattr(self, resource[:-1])133 retrieved_tags = self.tags_client.list_tags(134 resource, resource_object['id'])['tags']135 self.assertEqual(1, len(retrieved_tags))136 self.assertEqual(tag_names[i], retrieved_tags[0])137 # Check that the expected tag exists for each resource.138 self.tags_client.check_tag_existence(139 resource, resource_object['id'], tag_names[i])140 # Delete the tag and ensure it was deleted.141 self.tags_client.delete_tag(142 resource, resource_object['id'], tag_names[i])143 retrieved_tags = self.tags_client.list_tags(144 resource, resource_object['id'])['tags']145 self.assertEmpty(retrieved_tags)146 @decorators.idempotent_id('663a90f5-f334-4b44-afe0-c5fc1d408791')147 def test_update_and_delete_all_tags(self):148 self._create_tags_for_each_resource()149 for resource in self.SUPPORTED_RESOURCES:150 # Generate 3 new tag names.151 replace_tags = [data_utils.rand_name(152 self.__class__.__name__ + '-Tag') for _ in range(3)]153 # Replace the current tag with the 3 new tags and validate that the154 # current resource has the 3 new tags.155 resource_object = getattr(self, resource[:-1])156 updated_tags = self.tags_client.update_all_tags(157 resource, resource_object['id'], replace_tags)['tags']158 self.assertEqual(3, len(updated_tags))159 self.assertEqual(set(replace_tags), set(updated_tags))160 # Delete all the tags and check that they have been removed.161 self.tags_client.delete_all_tags(resource, resource_object['id'])162 for i in range(3):...

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