Best Python code snippet using tempest_python
test_user_messages.py
Source:test_user_messages.py
...30 'links']31class UserMessagesTest(base.VolumesV3AdminTest):32 min_microversion = '3.3'33 max_microversion = 'latest'34 def _create_user_message(self):35 """Trigger a 'no valid host' situation to generate a message."""36 bad_protocol = data_utils.rand_name('storage_protocol')37 bad_vendor = data_utils.rand_name('vendor_name')38 extra_specs = {'storage_protocol': bad_protocol,39 'vendor_name': bad_vendor}40 vol_type_name = data_utils.rand_name(41 self.__class__.__name__ + '-volume-type')42 bogus_type = self.create_volume_type(43 name=vol_type_name, extra_specs=extra_specs)44 params = {'volume_type': bogus_type['id'],45 'size': CONF.volume.volume_size}46 volume = self.create_volume(wait_until="error", **params)47 messages = self.messages_client.list_messages()['messages']48 message_id = None49 for message in messages:50 if message['resource_uuid'] == volume['id']:51 message_id = message['id']52 break53 self.assertIsNotNone(message_id, 'No user message generated for '54 'volume %s' % volume['id'])55 return message_id56 @decorators.idempotent_id('50f29e6e-f363-42e1-8ad1-f67ae7fd4d5a')57 def test_list_messages(self):58 self._create_user_message()59 messages = self.messages_client.list_messages()['messages']60 self.assertIsInstance(messages, list)61 for message in messages:62 for key in MESSAGE_KEYS:63 self.assertIn(key, message.keys(),64 'Missing expected key %s' % key)65 @decorators.idempotent_id('55a4a61e-c7b2-4ba0-a05d-b914bdef3070')66 def test_show_message(self):67 message_id = self._create_user_message()68 self.addCleanup(self.messages_client.delete_message, message_id)69 message = self.messages_client.show_message(message_id)['message']70 for key in MESSAGE_KEYS:71 self.assertIn(key, message.keys(), 'Missing expected key %s' % key)72 @decorators.idempotent_id('c6eb6901-cdcc-490f-b735-4fe251842aed')73 def test_delete_message(self):74 message_id = self._create_user_message()75 self.messages_client.delete_message(message_id)...
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!!