How to use _update_server_tags method in tempest

Best Python code snippet using tempest_python

test_server_tags.py

Source:test_server_tags.py Github

copy

Full Screen

...33 @classmethod34 def resource_setup(cls):35 super(ServerTagsTestJSON, cls).resource_setup()36 cls.server = cls.create_test_server(wait_until='ACTIVE')37 def _update_server_tags(self, server_id, tags):38 if not isinstance(tags, (list, tuple)):39 tags = [tags]40 for tag in tags:41 self.client.update_tag(server_id, tag)42 self.addCleanup(self.client.delete_all_tags, server_id)43 @decorators.idempotent_id('8d95abe2-c658-4c42-9a44-c0258500306b')44 def test_create_delete_tag(self):45 # Check that no tags exist.46 fetched_tags = self.client.list_tags(self.server['id'])['tags']47 self.assertEmpty(fetched_tags)48 # Add server tag to the server.49 assigned_tag = data_utils.rand_name('tag')50 self._update_server_tags(self.server['id'], assigned_tag)51 # Check that added tag exists.52 fetched_tags = self.client.list_tags(self.server['id'])['tags']53 self.assertEqual([assigned_tag], fetched_tags)54 # Remove assigned tag from server and check that it was removed.55 self.client.delete_tag(self.server['id'], assigned_tag)56 fetched_tags = self.client.list_tags(self.server['id'])['tags']57 self.assertEmpty(fetched_tags)58 @decorators.idempotent_id('a2c1af8c-127d-417d-974b-8115f7e3d831')59 def test_update_all_tags(self):60 # Add server tags to the server.61 tags = [data_utils.rand_name('tag'), data_utils.rand_name('tag')]62 self._update_server_tags(self.server['id'], tags)63 # Replace tags with new tags and check that they are present.64 new_tags = [data_utils.rand_name('tag'), data_utils.rand_name('tag')]65 replaced_tags = self.client.update_all_tags(66 self.server['id'], new_tags)['tags']67 six.assertCountEqual(self, new_tags, replaced_tags)68 # List the tags and check that the tags were replaced.69 fetched_tags = self.client.list_tags(self.server['id'])['tags']70 six.assertCountEqual(self, new_tags, fetched_tags)71 @decorators.idempotent_id('a63b2a74-e918-4b7c-bcab-10c855f3a57e')72 def test_delete_all_tags(self):73 # Add server tags to the server.74 assigned_tags = [data_utils.rand_name('tag'),75 data_utils.rand_name('tag')]76 self._update_server_tags(self.server['id'], assigned_tags)77 # Delete tags from the server and check that they were deleted.78 self.client.delete_all_tags(self.server['id'])79 fetched_tags = self.client.list_tags(self.server['id'])['tags']80 self.assertEmpty(fetched_tags)81 @decorators.idempotent_id('81279a66-61c3-4759-b830-a2dbe64cbe08')82 def test_check_tag_existence(self):83 # Add server tag to the server.84 assigned_tag = data_utils.rand_name('tag')85 self._update_server_tags(self.server['id'], assigned_tag)86 # Check that added tag exists. Throws a 404 if not found, else a 204,87 # which was already checked by the schema validation....

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