Best Python code snippet using tempest_python
test_server_metadata.py
Source:test_server_metadata.py
...29 super(ServerMetadataTestJSON, self).setUp()30 meta = {'key1': 'value1', 'key2': 'value2'}31 self.client.set_server_metadata(self.server_id, meta)['metadata']32 @test.idempotent_id('479da087-92b3-4dcf-aeb3-fd293b2d14ce')33 def test_list_server_metadata(self):34 # All metadata key/value pairs for a server should be returned35 resp_metadata = (self.client.list_server_metadata(self.server_id)36 ['metadata'])37 # Verify the expected metadata items are in the list38 expected = {'key1': 'value1', 'key2': 'value2'}39 self.assertEqual(expected, resp_metadata)40 @test.idempotent_id('211021f6-21de-4657-a68f-908878cfe251')41 def test_set_server_metadata(self):42 # The server's metadata should be replaced with the provided values43 # Create a new set of metadata for the server44 req_metadata = {'meta2': 'data2', 'meta3': 'data3'}45 self.client.set_server_metadata(self.server_id,46 req_metadata)['metadata']47 # Verify the expected values are correct, and that the48 # previous values have been removed49 resp_metadata = (self.client.list_server_metadata(self.server_id)50 ['metadata'])51 self.assertEqual(resp_metadata, req_metadata)52 @test.idempotent_id('344d981e-0c33-4997-8a5d-6c1d803e4134')53 def test_update_server_metadata(self):54 # The server's metadata values should be updated to the55 # provided values56 meta = {'key1': 'alt1', 'key3': 'value3'}57 self.client.update_server_metadata(self.server_id, meta)58 # Verify the values have been updated to the proper values59 resp_metadata = (self.client.list_server_metadata(self.server_id)60 ['metadata'])61 expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}62 self.assertEqual(expected, resp_metadata)63 @test.idempotent_id('0f58d402-e34a-481d-8af8-b392b17426d9')64 def test_update_metadata_empty_body(self):65 # The original metadata should not be lost if empty metadata body is66 # passed67 meta = {}68 self.client.update_server_metadata(self.server_id, meta)69 resp_metadata = (self.client.list_server_metadata(self.server_id)70 ['metadata'])71 expected = {'key1': 'value1', 'key2': 'value2'}72 self.assertEqual(expected, resp_metadata)73 @test.idempotent_id('3043c57d-7e0e-49a6-9a96-ad569c265e6a')74 def test_get_server_metadata_item(self):75 # The value for a specific metadata key should be returned76 meta = self.client.show_server_metadata_item(self.server_id,77 'key2')['meta']78 self.assertEqual('value2', meta['key2'])79 @test.idempotent_id('58c02d4f-5c67-40be-8744-d3fa5982eb1c')80 def test_set_server_metadata_item(self):81 # The item's value should be updated to the provided value82 # Update the metadata value83 meta = {'nova': 'alt'}84 self.client.set_server_metadata_item(self.server_id, 'nova', meta)85 # Verify the meta item's value has been updated86 resp_metadata = (self.client.list_server_metadata(self.server_id)87 ['metadata'])88 expected = {'key1': 'value1', 'key2': 'value2', 'nova': 'alt'}89 self.assertEqual(expected, resp_metadata)90 @test.idempotent_id('127642d6-4c7b-4486-b7cd-07265a378658')91 def test_delete_server_metadata_item(self):92 # The metadata value/key pair should be deleted from the server93 self.client.delete_server_metadata_item(self.server_id, 'key1')94 # Verify the metadata item has been removed95 resp_metadata = (self.client.list_server_metadata(self.server_id)96 ['metadata'])97 expected = {'key2': 'value2'}...
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!!