Best Python code snippet using tempest_python
test_flavors_extra_specs.py
Source:test_flavors_extra_specs.py
...60 # Assigning extra specs values that are to be set61 specs = {"key1": "value1", "key2": "value2"}62 # SET extra specs to the flavor created in setUp63 set_resp, set_body = \64 self.client.set_flavor_extra_spec(self.flavor['id'], specs)65 self.assertEqual(set_resp.status, 200)66 self.assertEqual(set_body, specs)67 # GET extra specs and verify68 get_resp, get_body = \69 self.client.get_flavor_extra_spec(self.flavor['id'])70 self.assertEqual(get_resp.status, 200)71 self.assertEqual(get_body, specs)72 # UNSET extra specs that were set in this test73 unset_resp, _ = \74 self.client.unset_flavor_extra_spec(self.flavor['id'], "key1")75 self.assertEqual(unset_resp.status, 200)76 @attr(type=['negative', 'gate'])77 def test_flavor_non_admin_set_keys(self):78 # Test to SET flavor extra spec as a user without admin privileges.79 specs = {"key1": "value1", "key2": "value2"}80 self.assertRaises(exceptions.Unauthorized,81 self.flavors_client.set_flavor_extra_spec,82 self.flavor['id'],83 specs)84 @attr(type='gate')85 def test_flavor_non_admin_get_keys(self):86 specs = {"key1": "value1", "key2": "value2"}87 set_resp, set_body = self.client.set_flavor_extra_spec(88 self.flavor['id'], specs)89 resp, body = self.flavors_client.get_flavor_extra_spec(90 self.flavor['id'])91 self.assertEqual(resp.status, 200)92 for key in specs:93 self.assertEqual(body[key], specs[key])94 @attr(type=['negative', 'gate'])95 def test_flavor_non_admin_unset_keys(self):96 specs = {"key1": "value1", "key2": "value2"}97 set_resp, set_body = self.client.set_flavor_extra_spec(98 self.flavor['id'], specs)99 self.assertRaises(exceptions.Unauthorized,100 self.flavors_client.unset_flavor_extra_spec,101 self.flavor['id'],102 'key1')103 @attr(type=['negative', 'gate'])104 def test_flavor_unset_nonexistent_key(self):105 nonexistent_key = rand_name('flavor_key')106 self.assertRaises(exceptions.NotFound,107 self.client.unset_flavor_extra_spec,108 self.flavor['id'],109 nonexistent_key)110class FlavorsExtraSpecsTestXML(FlavorsExtraSpecsTestJSON):111 _interface = 'xml'
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!!