Merge "Make set_flavor_extra_spec use **kwargs"
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index 6866c1a..6060e72 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -71,7 +71,7 @@
specs = {"key1": "value1", "key2": "value2"}
# SET extra specs to the flavor created in setUp
set_body = \
- self.client.set_flavor_extra_spec(self.flavor['id'], specs)
+ self.client.set_flavor_extra_spec(self.flavor['id'], **specs)
self.assertEqual(set_body, specs)
# GET extra specs and verify
get_body = self.client.list_flavor_extra_specs(self.flavor['id'])
@@ -96,7 +96,7 @@
@test.idempotent_id('a99dad88-ae1c-4fba-aeb4-32f898218bd0')
def test_flavor_non_admin_get_all_keys(self):
specs = {"key1": "value1", "key2": "value2"}
- self.client.set_flavor_extra_spec(self.flavor['id'], specs)
+ self.client.set_flavor_extra_spec(self.flavor['id'], **specs)
body = self.flavors_client.list_flavor_extra_specs(self.flavor['id'])
for key in specs:
@@ -104,8 +104,8 @@
@test.idempotent_id('12805a7f-39a3-4042-b989-701d5cad9c90')
def test_flavor_non_admin_get_specific_key(self):
- specs = {"key1": "value1", "key2": "value2"}
- body = self.client.set_flavor_extra_spec(self.flavor['id'], specs)
+ body = self.client.set_flavor_extra_spec(self.flavor['id'],
+ key1="value1", key2="value2")
self.assertEqual(body['key1'], 'value1')
self.assertIn('key2', body)
body = self.flavors_client.show_flavor_extra_spec(
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
index 8c5a103..fbb0822 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -70,19 +70,17 @@
@test.idempotent_id('a00a3b81-5641-45a8-ab2b-4a8ec41e1d7d')
def test_flavor_non_admin_set_keys(self):
# Test to SET flavor extra spec as a user without admin privileges.
- specs = {"key1": "value1", "key2": "value2"}
self.assertRaises(lib_exc.Forbidden,
self.flavors_client.set_flavor_extra_spec,
self.flavor['id'],
- specs)
+ key1="value1", key2="value2")
@test.attr(type=['negative'])
@test.idempotent_id('1ebf4ef8-759e-48fe-a801-d451d80476fb')
def test_flavor_non_admin_update_specific_key(self):
# non admin user is not allowed to update flavor extra spec
- specs = {"key1": "value1", "key2": "value2"}
body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
+ self.flavor['id'], key1="value1", key2="value2")
self.assertEqual(body['key1'], 'value1')
self.assertRaises(lib_exc.Forbidden,
self.flavors_client.
@@ -94,8 +92,8 @@
@test.attr(type=['negative'])
@test.idempotent_id('28f12249-27c7-44c1-8810-1f382f316b11')
def test_flavor_non_admin_unset_keys(self):
- specs = {"key1": "value1", "key2": "value2"}
- self.client.set_flavor_extra_spec(self.flavor['id'], specs)
+ self.client.set_flavor_extra_spec(self.flavor['id'],
+ key1="value1", key2="value2")
self.assertRaises(lib_exc.Forbidden,
self.flavors_client.unset_flavor_extra_spec,
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index b928f9f..ee2f74c 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -92,9 +92,9 @@
"""Returns the primary type of resource this client works with."""
return 'flavor'
- def set_flavor_extra_spec(self, flavor_id, specs):
+ def set_flavor_extra_spec(self, flavor_id, **kwargs):
"""Sets extra Specs to the mentioned flavor."""
- post_body = json.dumps({'extra_specs': specs})
+ post_body = json.dumps({'extra_specs': kwargs})
resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
post_body)
body = json.loads(body)