Added 'pool name' and 'flavor name' to response

'pool name and flavor name were being deleted from the response. I
'eliminated the pop() function thas was causing this.

This change is needed because in order to create an instance of pool
or a flavor, the 'name' attribute is required.

Change-Id: I36445838f532e9f282a4f839a0f583257c1f13d9
Closes-Bug: #1463474
This commit is contained in:
dynarro 2015-06-11 10:41:12 +02:00
parent 07a236121f
commit b13c7f1e7e
12 changed files with 19 additions and 15 deletions

View File

@ -178,6 +178,9 @@ class ResponseSchema(api.Api):
'type': 'number',
'minimum': -1
},
'name': {
'type': 'string'
},
'uri': {
'type': 'string'
},

View File

@ -219,6 +219,9 @@ class ResponseSchema(api.Api):
'type': 'number',
'minimum': -1
},
'name': {
'type': 'string'
},
'uri': {
'type': 'string'
},
@ -271,6 +274,9 @@ class ResponseSchema(api.Api):
'pool_detail': {
'type': 'object',
'properties': {
'name': {
'type': 'string'
},
'uri': {
'type': 'string'
},

View File

@ -158,6 +158,7 @@ class PoolsBaseTest(base.V1Base):
def _pool_expect(self, pool, xhref, xweight, xuri):
self.assertIn('href', pool)
self.assertIn('name', pool)
self.assertEqual(pool['href'], xhref)
self.assertIn('weight', pool)
self.assertEqual(pool['weight'], xweight)

View File

@ -174,6 +174,7 @@ class TestFlavorsMongoDB(base.V1_1Base):
def _flavor_expect(self, flavor, xhref, xpool):
self.assertIn('href', flavor)
self.assertIn('name', flavor)
self.assertEqual(flavor['href'], xhref)
self.assertIn('pool', flavor)
self.assertEqual(flavor['pool'], xpool)

View File

@ -166,6 +166,7 @@ class TestPoolsMongoDB(base.V1_1Base):
def _pool_expect(self, pool, xhref, xweight, xuri):
self.assertIn('href', pool)
self.assertIn('name', pool)
self.assertEqual(pool['href'], xhref)
self.assertIn('weight', pool)
self.assertEqual(pool['weight'], xweight)

View File

@ -174,6 +174,7 @@ class TestFlavorsMongoDB(base.V2Base):
def _flavor_expect(self, flavor, xhref, xpool):
self.assertIn('href', flavor)
self.assertIn('name', flavor)
self.assertEqual(flavor['href'], xhref)
self.assertIn('pool', flavor)
self.assertEqual(flavor['pool'], xpool)

View File

@ -165,6 +165,7 @@ class TestPoolsMongoDB(base.V2Base):
def _pool_expect(self, pool, xhref, xweight, xuri):
self.assertIn('href', pool)
self.assertIn('name', pool)
self.assertEqual(pool['href'], xhref)
self.assertIn('weight', pool)
self.assertEqual(pool['weight'], xweight)

View File

@ -94,7 +94,7 @@ class Listing(object):
store['marker'] = next(cursor)
for entry in pools:
entry['href'] = request.path + '/' + entry.pop('name')
entry['href'] = request.path + '/' + entry['name']
results['links'] = [
{
@ -147,8 +147,6 @@ class Resource(object):
data['href'] = request.path
# remove the name entry - it isn't needed on GET
del data['name']
response.body = transport_utils.to_json(data)
response.content_location = request.relative_uri

View File

@ -72,7 +72,7 @@ class Listing(object):
store['marker'] = next(cursor)
for entry in flavors:
entry['href'] = request.path + '/' + entry.pop('name')
entry['href'] = request.path + '/' + entry['name']
results['links'] = [
{
@ -126,8 +126,6 @@ class Resource(object):
data['href'] = request.path
# remove the name entry - it isn't needed on GET
del data['name']
response.body = transport_utils.to_json(data)
def on_put(self, request, response, project_id, flavor):

View File

@ -95,7 +95,7 @@ class Listing(object):
store['marker'] = next(cursor)
for entry in pools:
entry['href'] = request.path + '/' + entry.pop('name')
entry['href'] = request.path + '/' + entry['name']
results['links'] = [
{
@ -150,8 +150,6 @@ class Resource(object):
data['href'] = request.path
# remove the name entry - it isn't needed on GET
del data['name']
response.body = transport_utils.to_json(data)
def on_put(self, request, response, project_id, pool):

View File

@ -73,7 +73,7 @@ class Listing(object):
store['marker'] = next(cursor)
for entry in flavors:
entry['href'] = request.path + '/' + entry.pop('name')
entry['href'] = request.path + '/' + entry['name']
if detailed:
caps = self._pools_ctrl.capabilities(group=entry['pool'])
entry['capabilities'] = [str(cap).split('.')[-1]
@ -136,8 +136,6 @@ class Resource(object):
data['href'] = request.path
# remove the name entry - it isn't needed on GET
del data['name']
response.body = transport_utils.to_json(data)
def on_put(self, request, response, project_id, flavor):

View File

@ -95,7 +95,7 @@ class Listing(object):
store['marker'] = next(cursor)
for entry in pools:
entry['href'] = request.path + '/' + entry.pop('name')
entry['href'] = request.path + '/' + entry['name']
results['links'] = [
{
@ -150,8 +150,6 @@ class Resource(object):
data['href'] = request.path
# remove the name entry - it isn't needed on GET
del data['name']
response.body = transport_utils.to_json(data)
def on_put(self, request, response, project_id, pool):