Add a flavor test for getting a specified key value API
Test for GET v2/.{tenant_id}./flavors/.{flavor_id}./os-extra_specs/
.{key_id} that gets the value of the specified key for this flavor.
Change-Id: Id9941604aff9c583b9f2d394ba2299aad7dafec8
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index fb6a463..bf55da8 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -79,6 +79,12 @@
self.client.get_flavor_extra_spec(self.flavor['id'])
self.assertEqual(get_resp.status, 200)
self.assertEqual(get_body, specs)
+ # GET a key value and verify
+ get_resp, get_body = \
+ self.client.get_flavor_extra_spec_with_key(self.flavor['id'],
+ "key2")
+ self.assertEqual(get_resp.status, 200)
+ self.assertEqual(get_body, specs['key2'])
# UNSET extra specs that were set in this test
unset_resp, _ = \
self.client.unset_flavor_extra_spec(self.flavor['id'], "key1")
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index c3b568d..dc05e3e 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -102,6 +102,13 @@
body = json.loads(body)
return resp, body['extra_specs']
+ def get_flavor_extra_spec_with_key(self, flavor_id, key):
+ """Gets a specified key value for the mentioned flavor."""
+ resp, body = self.get('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
+ key))
+ body = json.loads(body)
+ return resp, body[key]
+
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets extra Specs from the mentioned flavor."""
return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
diff --git a/tempest/services/compute/xml/flavors_client.py b/tempest/services/compute/xml/flavors_client.py
index c5886ee..c7ed044 100644
--- a/tempest/services/compute/xml/flavors_client.py
+++ b/tempest/services/compute/xml/flavors_client.py
@@ -148,6 +148,13 @@
body = xml_to_json(etree.fromstring(body))
return resp, body
+ def get_flavor_extra_spec_with_key(self, flavor_id, key):
+ """Gets a specified key detail for the mentioned flavor."""
+ resp, body = self.get('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
+ key), self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
+
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets an extra spec based on the mentioned flavor and key."""
return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),