How to use create_update_or_delete_container_metadata method in tempest

Best Python code snippet using tempest_python

test_container_staticweb.py

Source:test_container_staticweb.py Github

copy

Full Screen

...26 # Create test container and create one object in it27 cls.container_name = cls.create_container()28 cls.object_name, cls.object_data = cls.create_object(29 cls.container_name)30 cls.container_client.create_update_or_delete_container_metadata(31 cls.container_name,32 create_update_metadata=headers_public_read_acl,33 create_update_metadata_prefix="X-Container-")34 @classmethod35 def resource_cleanup(cls):36 cls.delete_containers()37 super(StaticWebTest, cls).resource_cleanup()38 @decorators.idempotent_id('c1f055ab-621d-4a6a-831f-846fcb578b8b')39 @utils.requires_ext(extension='staticweb', service='object')40 def test_web_index(self):41 headers = {'web-index': self.object_name}42 self.container_client.create_update_or_delete_container_metadata(43 self.container_name, create_update_metadata=headers)44 # Maintain original headers, no auth added45 self.account_client.auth_provider.set_alt_auth_data(46 request_part='headers',47 auth_data=None48 )49 # test GET on http://account_url/container_name50 # we should retrieve the self.object_name file51 resp, body = self.account_client.request("GET",52 self.container_name,53 headers={})54 # This request is equivalent to GET object55 self.assertHeaders(resp, 'Object', 'GET')56 self.assertEqual(body, self.object_data)57 # clean up before exiting58 self.container_client.create_update_or_delete_container_metadata(59 self.container_name,60 create_update_metadata={'web-index': ""})61 _, body = self.container_client.list_container_metadata(62 self.container_name)63 self.assertNotIn('x-container-meta-web-index', body)64 @decorators.idempotent_id('941814cf-db9e-4b21-8112-2b6d0af10ee5')65 @utils.requires_ext(extension='staticweb', service='object')66 def test_web_listing(self):67 headers = {'web-listings': 'true'}68 self.container_client.create_update_or_delete_container_metadata(69 self.container_name, create_update_metadata=headers)70 # test GET on http://account_url/container_name71 # we should retrieve a listing of objects72 resp, body = self.account_client.request("GET",73 self.container_name,74 headers={})75 # The target of the request is not any Swift resource. Therefore, the76 # existence of response header is checked without a custom matcher.77 self.assertIn('content-length', resp)78 self.assertIn('content-type', resp)79 self.assertIn('x-trans-id', resp)80 self.assertIn('date', resp)81 # Check only the format of common headers with custom matcher82 self.assertThat(resp, custom_matchers.AreAllWellFormatted())83 self.assertIn(self.object_name, body.decode())84 # clean up before exiting85 self.container_client.create_update_or_delete_container_metadata(86 self.container_name,87 create_update_metadata={'web-listings': ""})88 _, body = self.container_client.list_container_metadata(89 self.container_name)90 self.assertNotIn('x-container-meta-web-listings', body)91 @decorators.idempotent_id('bc37ec94-43c8-4990-842e-0e5e02fc8926')92 @utils.requires_ext(extension='staticweb', service='object')93 def test_web_listing_css(self):94 headers = {'web-listings': 'true',95 'web-listings-css': 'listings.css'}96 self.container_client.create_update_or_delete_container_metadata(97 self.container_name, create_update_metadata=headers)98 # Maintain original headers, no auth added99 self.account_client.auth_provider.set_alt_auth_data(100 request_part='headers',101 auth_data=None102 )103 # test GET on http://account_url/container_name104 # we should retrieve a listing of objects105 _, body = self.account_client.request("GET", self.container_name,106 headers={})107 self.assertIn(self.object_name, body.decode())108 css = '<link rel="stylesheet" type="text/css" href="listings.css" />'109 self.assertIn(css, body.decode())110 @decorators.idempotent_id('f18b4bef-212e-45e7-b3ca-59af3a465f82')111 @utils.requires_ext(extension='staticweb', service='object')112 def test_web_error(self):113 headers = {'web-listings': 'true',114 'web-error': self.object_name}115 self.container_client.create_update_or_delete_container_metadata(116 self.container_name, create_update_metadata=headers)117 # Create object to return when requested object not found118 object_name_404 = "404" + self.object_name119 object_data_404 = data_utils.arbitrary_string()120 self.object_client.create_object(self.container_name,121 object_name_404,122 object_data_404)123 # Do not set auth in HTTP headers for next request124 self.object_client.auth_provider.set_alt_auth_data(125 request_part='headers',126 auth_data=None127 )128 # Request non-existing object129 self.assertRaises(...

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