From 4c5acdb22c67bd23712e11e3576783275cc26af5 Mon Sep 17 00:00:00 2001 From: Anusha Ramineni Date: Thu, 20 Aug 2015 10:51:57 +0530 Subject: [PATCH] Full response for database flavor client methods Provide the entire response object for all methods of the DatabaseFlavorsClient partially implements: blueprint method-return-value-and-move-service-clients-to-lib Change-Id: I4909c87818cfbd2a34824b402265c70ced0cc87c --- tempest/api/database/flavors/test_flavors.py | 12 +++++++----- tempest/services/database/json/flavors_client.py | 7 +++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py index c97ddd7a18..62c1e05eb4 100644 --- a/tempest/api/database/flavors/test_flavors.py +++ b/tempest/api/database/flavors/test_flavors.py @@ -28,7 +28,8 @@ class DatabaseFlavorsTest(base.BaseDatabaseTest): @test.idempotent_id('c94b825e-0132-4686-8049-8a4a2bc09525') def test_get_db_flavor(self): # The expected flavor details should be returned - flavor = self.client.get_db_flavor_details(self.db_flavor_ref) + flavor = (self.client.get_db_flavor_details(self.db_flavor_ref) + ['flavor']) self.assertEqual(self.db_flavor_ref, str(flavor['id'])) self.assertIn('ram', flavor) self.assertIn('links', flavor) @@ -37,9 +38,10 @@ class DatabaseFlavorsTest(base.BaseDatabaseTest): @test.attr(type='smoke') @test.idempotent_id('685025d6-0cec-4673-8a8d-995cb8e0d3bb') def test_list_db_flavors(self): - flavor = self.client.get_db_flavor_details(self.db_flavor_ref) + flavor = (self.client.get_db_flavor_details(self.db_flavor_ref) + ['flavor']) # List of all flavors should contain the expected flavor - flavors = self.client.list_db_flavors() + flavors = self.client.list_db_flavors()['flavors'] self.assertIn(flavor, flavors) def _check_values(self, names, db_flavor, os_flavor, in_db=True): @@ -57,7 +59,7 @@ class DatabaseFlavorsTest(base.BaseDatabaseTest): @test.idempotent_id('afb2667f-4ec2-4925-bcb7-313fdcffb80d') @test.services('compute') def test_compare_db_flavors_with_os(self): - db_flavors = self.client.list_db_flavors() + db_flavors = self.client.list_db_flavors()['flavors'] os_flavors = (self.os_flavors_client.list_flavors(detail=True) ['flavors']) self.assertEqual(len(os_flavors), len(db_flavors), @@ -65,7 +67,7 @@ class DatabaseFlavorsTest(base.BaseDatabaseTest): (os_flavors, db_flavors)) for os_flavor in os_flavors: db_flavor =\ - self.client.get_db_flavor_details(os_flavor['id']) + self.client.get_db_flavor_details(os_flavor['id'])['flavor'] self._check_values(['id', 'name', 'ram'], db_flavor, os_flavor) self._check_values(['disk', 'vcpus', 'swap'], db_flavor, os_flavor, in_db=False) diff --git a/tempest/services/database/json/flavors_client.py b/tempest/services/database/json/flavors_client.py index 4fe5a46488..88feb176ad 100644 --- a/tempest/services/database/json/flavors_client.py +++ b/tempest/services/database/json/flavors_client.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_serialization import jsonutils as json import urllib from tempest.common import service_client @@ -27,9 +28,11 @@ class DatabaseFlavorsClient(service_client.ServiceClient): resp, body = self.get(url) self.expected_success(200, resp.status) - return service_client.ResponseBodyList(resp, self._parse_resp(body)) + body = json.loads(body) + return service_client.ResponseBody(resp, body) def get_db_flavor_details(self, db_flavor_id): resp, body = self.get("flavors/%s" % str(db_flavor_id)) self.expected_success(200, resp.status) - return service_client.ResponseBody(resp, self._parse_resp(body)) + body = json.loads(body) + return service_client.ResponseBody(resp, body)