Merge "Full response for database flavor client methods"

This commit is contained in:
Jenkins 2015-09-11 11:20:38 +00:00 committed by Gerrit Code Review
commit 0318d13d77
2 changed files with 12 additions and 7 deletions

View File

@ -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)

View File

@ -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)