How to use list_container_metadata method in tempest

Best Python code snippet using tempest_python

test_container_services.py

Source:test_container_services.py Github

copy

Full Screen

...61 container_name,62 metadata=metadata)63 self.containers.append(container_name)64 self.assertHeaders(resp, 'Container', 'PUT')65 resp, _ = self.container_client.list_container_metadata(66 container_name)67 # if the value of metadata is blank, metadata is not registered68 # in the server69 self.assertNotIn('x-container-meta-test-container-meta', resp)70 @test.idempotent_id('e1e8df32-7b22-44e1-aa08-ccfd8d446b58')71 def test_create_container_with_metadata_value(self):72 # create container with metadata value73 container_name = data_utils.rand_name(name='TestContainer')74 metadata = {'test-container-meta': 'Meta1'}75 resp, _ = self.container_client.create_container(76 container_name,77 metadata=metadata)78 self.containers.append(container_name)79 self.assertHeaders(resp, 'Container', 'PUT')80 resp, _ = self.container_client.list_container_metadata(81 container_name)82 self.assertIn('x-container-meta-test-container-meta', resp)83 self.assertEqual(resp['x-container-meta-test-container-meta'],84 metadata['test-container-meta'])85 @test.idempotent_id('24d16451-1c0c-4e4f-b59c-9840a3aba40e')86 def test_create_container_with_remove_metadata_key(self):87 # create container with the blank value of remove metadata88 container_name = data_utils.rand_name(name='TestContainer')89 metadata_1 = {'test-container-meta': 'Meta1'}90 self.container_client.create_container(91 container_name,92 metadata=metadata_1)93 self.containers.append(container_name)94 metadata_2 = {'test-container-meta': ''}95 resp, _ = self.container_client.create_container(96 container_name,97 remove_metadata=metadata_2)98 self.assertHeaders(resp, 'Container', 'PUT')99 resp, _ = self.container_client.list_container_metadata(100 container_name)101 self.assertNotIn('x-container-meta-test-container-meta', resp)102 @test.idempotent_id('8a21ebad-a5c7-4e29-b428-384edc8cd156')103 def test_create_container_with_remove_metadata_value(self):104 # create container with remove metadata105 container_name = data_utils.rand_name(name='TestContainer')106 metadata = {'test-container-meta': 'Meta1'}107 self.container_client.create_container(container_name,108 metadata=metadata)109 self.containers.append(container_name)110 resp, _ = self.container_client.create_container(111 container_name,112 remove_metadata=metadata)113 self.assertHeaders(resp, 'Container', 'PUT')114 resp, _ = self.container_client.list_container_metadata(115 container_name)116 self.assertNotIn('x-container-meta-test-container-meta', resp)117 @test.idempotent_id('95d3a249-b702-4082-a2c4-14bb860cf06a')118 def test_delete_container(self):119 # create a container120 container_name = self._create_container()121 # delete container, success asserted within122 resp, _ = self.container_client.delete_container(container_name)123 self.assertHeaders(resp, 'Container', 'DELETE')124 self.containers.remove(container_name)125 @test.attr(type='smoke')126 @test.idempotent_id('312ff6bd-5290-497f-bda1-7c5fec6697ab')127 def test_list_container_contents(self):128 # get container contents list129 container_name = self._create_container()130 object_name = self._create_object(container_name)131 resp, object_list = self.container_client.list_container_contents(132 container_name)133 self.assertHeaders(resp, 'Container', 'GET')134 self.assertEqual(object_name, object_list.strip('\n'))135 @test.idempotent_id('4646ac2d-9bfb-4c7d-a3c5-0f527402b3df')136 def test_list_container_contents_with_no_object(self):137 # get empty container contents list138 container_name = self._create_container()139 resp, object_list = self.container_client.list_container_contents(140 container_name)141 self.assertHeaders(resp, 'Container', 'GET')142 self.assertEqual('', object_list.strip('\n'))143 @test.idempotent_id('fe323a32-57b9-4704-a996-2e68f83b09bc')144 def test_list_container_contents_with_delimiter(self):145 # get container contents list using delimiter param146 container_name = self._create_container()147 object_name = data_utils.rand_name(name='TestObject/')148 self._create_object(container_name, object_name)149 params = {'delimiter': '/'}150 resp, object_list = self.container_client.list_container_contents(151 container_name,152 params=params)153 self.assertHeaders(resp, 'Container', 'GET')154 self.assertEqual(object_name.split('/')[0], object_list.strip('/\n'))155 @test.idempotent_id('55b4fa5c-e12e-4ca9-8fcf-a79afe118522')156 def test_list_container_contents_with_end_marker(self):157 # get container contents list using end_marker param158 container_name = self._create_container()159 object_name = self._create_object(container_name)160 params = {'end_marker': 'ZzzzObject1234567890'}161 resp, object_list = self.container_client.list_container_contents(162 container_name,163 params=params)164 self.assertHeaders(resp, 'Container', 'GET')165 self.assertEqual(object_name, object_list.strip('\n'))166 @test.idempotent_id('196f5034-6ab0-4032-9da9-a937bbb9fba9')167 def test_list_container_contents_with_format_json(self):168 # get container contents list using format_json param169 container_name = self._create_container()170 self._create_object(container_name)171 params = {'format': 'json'}172 resp, object_list = self.container_client.list_container_contents(173 container_name,174 params=params)175 self.assertHeaders(resp, 'Container', 'GET')176 self.assertIsNotNone(object_list)177 self.assertTrue([c['name'] for c in object_list])178 self.assertTrue([c['hash'] for c in object_list])179 self.assertTrue([c['bytes'] for c in object_list])180 self.assertTrue([c['content_type'] for c in object_list])181 self.assertTrue([c['last_modified'] for c in object_list])182 @test.idempotent_id('655a53ca-4d15-408c-a377-f4c6dbd0a1fa')183 def test_list_container_contents_with_format_xml(self):184 # get container contents list using format_xml param185 container_name = self._create_container()186 self._create_object(container_name)187 params = {'format': 'xml'}188 resp, object_list = self.container_client.list_container_contents(189 container_name,190 params=params)191 self.assertHeaders(resp, 'Container', 'GET')192 self.assertIsNotNone(object_list)193 self.assertEqual(object_list.tag, 'container')194 self.assertTrue('name' in object_list.keys())195 self.assertEqual(object_list.find(".//object").tag, 'object')196 self.assertEqual(object_list.find(".//name").tag, 'name')197 self.assertEqual(object_list.find(".//hash").tag, 'hash')198 self.assertEqual(object_list.find(".//bytes").tag, 'bytes')199 self.assertEqual(object_list.find(".//content_type").tag,200 'content_type')201 self.assertEqual(object_list.find(".//last_modified").tag,202 'last_modified')203 @test.idempotent_id('297ec38b-2b61-4ff4-bcd1-7fa055e97b61')204 def test_list_container_contents_with_limit(self):205 # get container contents list using limit param206 container_name = self._create_container()207 object_name = self._create_object(container_name)208 params = {'limit': data_utils.rand_int_id(1, 10000)}209 resp, object_list = self.container_client.list_container_contents(210 container_name,211 params=params)212 self.assertHeaders(resp, 'Container', 'GET')213 self.assertEqual(object_name, object_list.strip('\n'))214 @test.idempotent_id('c31ddc63-2a58-4f6b-b25c-94d2937e6867')215 def test_list_container_contents_with_marker(self):216 # get container contents list using marker param217 container_name = self._create_container()218 object_name = self._create_object(container_name)219 params = {'marker': 'AaaaObject1234567890'}220 resp, object_list = self.container_client.list_container_contents(221 container_name,222 params=params)223 self.assertHeaders(resp, 'Container', 'GET')224 self.assertEqual(object_name, object_list.strip('\n'))225 @test.idempotent_id('58ca6cc9-6af0-408d-aaec-2a6a7b2f0df9')226 def test_list_container_contents_with_path(self):227 # get container contents list using path param228 container_name = self._create_container()229 object_name = data_utils.rand_name(name='Swift/TestObject')230 self._create_object(container_name, object_name)231 params = {'path': 'Swift'}232 resp, object_list = self.container_client.list_container_contents(233 container_name,234 params=params)235 self.assertHeaders(resp, 'Container', 'GET')236 self.assertEqual(object_name, object_list.strip('\n'))237 @test.idempotent_id('77e742c7-caf2-4ec9-8aa4-f7d509a3344c')238 def test_list_container_contents_with_prefix(self):239 # get container contents list using prefix param240 container_name = self._create_container()241 object_name = self._create_object(container_name)242 prefix_key = object_name[0:8]243 params = {'prefix': prefix_key}244 resp, object_list = self.container_client.list_container_contents(245 container_name,246 params=params)247 self.assertHeaders(resp, 'Container', 'GET')248 self.assertEqual(object_name, object_list.strip('\n'))249 @test.attr(type='smoke')250 @test.idempotent_id('96e68f0e-19ec-4aa2-86f3-adc6a45e14dd')251 def test_list_container_metadata(self):252 # List container metadata253 container_name = self._create_container()254 metadata = {'name': 'Pictures'}255 self.container_client.update_container_metadata(256 container_name,257 metadata=metadata)258 resp, _ = self.container_client.list_container_metadata(259 container_name)260 self.assertHeaders(resp, 'Container', 'HEAD')261 self.assertIn('x-container-meta-name', resp)262 self.assertEqual(resp['x-container-meta-name'], metadata['name'])263 @test.idempotent_id('a2faf936-6b13-4f8d-92a2-c2278355821e')264 def test_list_no_container_metadata(self):265 # HEAD container without metadata266 container_name = self._create_container()267 resp, _ = self.container_client.list_container_metadata(268 container_name)269 self.assertHeaders(resp, 'Container', 'HEAD')270 self.assertNotIn('x-container-meta-', str(resp))271 @test.idempotent_id('cf19bc0b-7e16-4a5a-aaed-cb0c2fe8deef')272 def test_update_container_metadata_with_create_and_delete_metadata(self):273 # Send one request of adding and deleting metadata274 container_name = data_utils.rand_name(name='TestContainer')275 metadata_1 = {'test-container-meta1': 'Meta1'}276 self.container_client.create_container(container_name,277 metadata=metadata_1)278 self.containers.append(container_name)279 metadata_2 = {'test-container-meta2': 'Meta2'}280 resp, _ = self.container_client.update_container_metadata(281 container_name,282 metadata=metadata_2,283 remove_metadata=metadata_1)284 self.assertHeaders(resp, 'Container', 'POST')285 resp, _ = self.container_client.list_container_metadata(286 container_name)287 self.assertNotIn('x-container-meta-test-container-meta1', resp)288 self.assertIn('x-container-meta-test-container-meta2', resp)289 self.assertEqual(resp['x-container-meta-test-container-meta2'],290 metadata_2['test-container-meta2'])291 @test.idempotent_id('2ae5f295-4bf1-4e04-bfad-21e54b62cec5')292 def test_update_container_metadata_with_create_metadata(self):293 # update container metadata using add metadata294 container_name = self._create_container()295 metadata = {'test-container-meta1': 'Meta1'}296 resp, _ = self.container_client.update_container_metadata(297 container_name,298 metadata=metadata)299 self.assertHeaders(resp, 'Container', 'POST')300 resp, _ = self.container_client.list_container_metadata(301 container_name)302 self.assertIn('x-container-meta-test-container-meta1', resp)303 self.assertEqual(resp['x-container-meta-test-container-meta1'],304 metadata['test-container-meta1'])305 @test.idempotent_id('3a5ce7d4-6e4b-47d0-9d87-7cd42c325094')306 def test_update_container_metadata_with_delete_metadata(self):307 # update container metadata using delete metadata308 container_name = data_utils.rand_name(name='TestContainer')309 metadata = {'test-container-meta1': 'Meta1'}310 self.container_client.create_container(container_name,311 metadata=metadata)312 self.containers.append(container_name)313 resp, _ = self.container_client.delete_container_metadata(314 container_name,315 metadata=metadata)316 self.assertHeaders(resp, 'Container', 'POST')317 resp, _ = self.container_client.list_container_metadata(318 container_name)319 self.assertNotIn('x-container-meta-test-container-meta1', resp)320 @test.idempotent_id('31f40a5f-6a52-4314-8794-cd89baed3040')321 def test_update_container_metadata_with_create_metadata_key(self):322 # update container metadata with a blank value of metadata323 container_name = self._create_container()324 metadata = {'test-container-meta1': ''}325 resp, _ = self.container_client.update_container_metadata(326 container_name,327 metadata=metadata)328 self.assertHeaders(resp, 'Container', 'POST')329 resp, _ = self.container_client.list_container_metadata(330 container_name)331 self.assertNotIn('x-container-meta-test-container-meta1', resp)332 @test.idempotent_id('a2e36378-6f1f-43f4-840a-ffd9cfd61914')333 def test_update_container_metadata_with_delete_metadata_key(self):334 # update container metadata with a blank value of metadata335 container_name = data_utils.rand_name(name='TestContainer')336 metadata = {'test-container-meta1': 'Meta1'}337 self.container_client.create_container(container_name,338 metadata=metadata)339 self.containers.append(container_name)340 metadata = {'test-container-meta1': ''}341 resp, _ = self.container_client.delete_container_metadata(342 container_name,343 metadata=metadata)344 self.assertHeaders(resp, 'Container', 'POST')345 resp, _ = self.container_client.list_container_metadata(container_name)...

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