Return complete response from flavors_client part-2
Currently compute flavors_client returns Response by removing
top key from Response.
For example-
return service_client.ResponseBody(resp, body['flavor_access'])
As service clients are in direction to move to Tempest-lib, all
service clients should return Response without any truncation.
One good example is Resource pagination links which are lost with current
way of return value. Resource pagination links are present in parallel
(not inside) to top key of Response.
This patch makes flavor-access/extra-specs methods of compute flavors_client
to return complete Response body.
Implements: blueprint method-return-value-and-move-service-clients-to-lib
Change-Id: Id153ba7b5ff838532fd7bf0e2b72815141c2e250
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index b60272f..7a3e8db 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -62,7 +62,8 @@
id=new_flavor_id,
is_public='False')['flavor']
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- flavor_access = self.client.list_flavor_access(new_flavor_id)
+ flavor_access = (self.client.list_flavor_access(new_flavor_id)
+ ['flavor_access'])
self.assertEqual(len(flavor_access), 0, str(flavor_access))
@test.idempotent_id('59e622f6-bdf6-45e3-8ba8-fedad905a6b4')
@@ -81,8 +82,9 @@
"tenant_id": str(self.tenant_id),
"flavor_id": str(new_flavor['id']),
}
- add_body = \
- self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
+ add_body = (self.client.add_flavor_access(new_flavor['id'],
+ self.tenant_id)
+ ['flavor_access'])
self.assertIn(resp_body, add_body)
# The flavor is present in list.
@@ -90,8 +92,9 @@
self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))
# Remove flavor access from a tenant.
- remove_body = \
- self.client.remove_flavor_access(new_flavor['id'], self.tenant_id)
+ remove_body = (self.client.remove_flavor_access(new_flavor['id'],
+ self.tenant_id)
+ ['flavor_access'])
self.assertNotIn(resp_body, remove_body)
# The flavor is not present in list.
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index 2cdaa62..25dce6a 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -71,11 +71,12 @@
# Assigning extra specs values that are to be set
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)
+ set_body = self.client.set_flavor_extra_spec(self.flavor['id'],
+ **specs)['extra_specs']
self.assertEqual(set_body, specs)
# GET extra specs and verify
- get_body = self.client.list_flavor_extra_specs(self.flavor['id'])
+ get_body = (self.client.list_flavor_extra_specs(self.flavor['id'])
+ ['extra_specs'])
self.assertEqual(get_body, specs)
# UPDATE the value of the extra specs key1
@@ -87,7 +88,8 @@
# GET extra specs and verify the value of the key2
# is the same as before
- get_body = self.client.list_flavor_extra_specs(self.flavor['id'])
+ get_body = (self.client.list_flavor_extra_specs(self.flavor['id'])
+ ['extra_specs'])
self.assertEqual(get_body, {"key1": "value", "key2": "value2"})
# UNSET extra specs that were set in this test
@@ -98,7 +100,8 @@
def test_flavor_non_admin_get_all_keys(self):
specs = {"key1": "value1", "key2": "value2"}
self.client.set_flavor_extra_spec(self.flavor['id'], **specs)
- body = self.flavors_client.list_flavor_extra_specs(self.flavor['id'])
+ body = (self.flavors_client.list_flavor_extra_specs(self.flavor['id'])
+ ['extra_specs'])
for key in specs:
self.assertEqual(body[key], specs[key])
@@ -106,7 +109,8 @@
@test.idempotent_id('12805a7f-39a3-4042-b989-701d5cad9c90')
def test_flavor_non_admin_get_specific_key(self):
body = self.client.set_flavor_extra_spec(self.flavor['id'],
- key1="value1", key2="value2")
+ key1="value1",
+ key2="value2")['extra_specs']
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 20fada8..aa95454 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -81,7 +81,7 @@
def test_flavor_non_admin_update_specific_key(self):
# non admin user is not allowed to update flavor extra spec
body = self.client.set_flavor_extra_spec(
- self.flavor['id'], key1="value1", key2="value2")
+ self.flavor['id'], key1="value1", key2="value2")['extra_specs']
self.assertEqual(body['key1'], 'value1')
self.assertRaises(lib_exc.Forbidden,
self.flavors_client.
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index de3fd75..2c32d30 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -95,7 +95,7 @@
body = json.loads(body)
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
resp, body)
- return service_client.ResponseBody(resp, body['extra_specs'])
+ return service_client.ResponseBody(resp, body)
def list_flavor_extra_specs(self, flavor_id):
"""Gets extra Specs details of the mentioned flavor."""
@@ -103,7 +103,7 @@
body = json.loads(body)
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
resp, body)
- return service_client.ResponseBody(resp, body['extra_specs'])
+ return service_client.ResponseBody(resp, body)
def show_flavor_extra_spec(self, flavor_id, key):
"""Gets extra Specs key-value of the mentioned flavor and key."""
@@ -138,7 +138,7 @@
body = json.loads(body)
self.validate_response(schema_access.add_remove_list_flavor_access,
resp, body)
- return service_client.ResponseBodyList(resp, body['flavor_access'])
+ return service_client.ResponseBody(resp, body)
def add_flavor_access(self, flavor_id, tenant_id):
"""Add flavor access for the specified tenant."""
@@ -152,7 +152,7 @@
body = json.loads(body)
self.validate_response(schema_access.add_remove_list_flavor_access,
resp, body)
- return service_client.ResponseBodyList(resp, body['flavor_access'])
+ return service_client.ResponseBody(resp, body)
def remove_flavor_access(self, flavor_id, tenant_id):
"""Remove flavor access from the specified tenant."""
@@ -166,4 +166,4 @@
body = json.loads(body)
self.validate_response(schema_access.add_remove_list_flavor_access,
resp, body)
- return service_client.ResponseBody(resp, body['flavor_access'])
+ return service_client.ResponseBody(resp, body)