diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py index b60272f589..7a3e8db9da 100644 --- a/tempest/api/compute/admin/test_flavors_access.py +++ b/tempest/api/compute/admin/test_flavors_access.py @@ -62,7 +62,8 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest): 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 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest): "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 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest): 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 2cdaa62d94..25dce6a1f5 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 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest): # 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 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest): # 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 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest): 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 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest): @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 20fada84a5..aa95454519 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 @@ class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest): 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 de3fd75b27..2c32d30cc3 100644 --- a/tempest/services/compute/json/flavors_client.py +++ b/tempest/services/compute/json/flavors_client.py @@ -95,7 +95,7 @@ class FlavorsClient(service_client.ServiceClient): 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 @@ class FlavorsClient(service_client.ServiceClient): 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 @@ class FlavorsClient(service_client.ServiceClient): 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 @@ class FlavorsClient(service_client.ServiceClient): 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 @@ class FlavorsClient(service_client.ServiceClient): 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)