Get HTTP Patch test working with Bay REST API

Change-Id: I2401bd32e06e77f5f605b9ed5c3bcdb341a5c3f0
This commit is contained in:
Davanum Srinivas
2014-12-04 07:36:36 -05:00
parent 219b27fc63
commit 3db1457eeb
2 changed files with 16 additions and 13 deletions
+10 -6
View File
@@ -292,14 +292,18 @@ class BaysController(rest.RestController):
if rpc_bay[field] != patch_val:
rpc_bay[field] = patch_val
rpc_bay = objects.Node.get_by_id(pecan.request.context,
rpc_bay.bay_id)
topic = pecan.request.rpcapi.get_topic_for(rpc_bay)
if hasattr(pecan.request, 'rpcapi'):
rpc_bay = objects.Bay.get_by_id(pecan.request.context,
rpc_bay.bay_id)
topic = pecan.request.rpcapi.get_topic_for(rpc_bay)
new_bay = pecan.request.rpcapi.update_bay(
pecan.request.context, rpc_bay, topic)
new_bay = pecan.request.rpcapi.update_bay(
pecan.request.context, rpc_bay, topic)
return Bay.convert_with_links(new_bay)
return Bay.convert_with_links(new_bay)
else:
rpc_bay.save()
return Bay.convert_with_links(rpc_bay)
@wsme_pecan.wsexpose(None, types.uuid, status_code=204)
def delete(self, bay_uuid):
+6 -7
View File
@@ -91,13 +91,12 @@ class TestBayController(db_base.DbTestCase):
self.assertEqual(response.status_int, 200)
# Update the description
# params = ('{"uuid":"' + c.get('uuid') + '", '
# '"type": "virt", '
# '"name": "bay_example_B"}')
# response = self.app.put('/v1/bays,
# params=params,
# content_type='application/json')
# self.assertEqual(response.status_int, 200)
params = [{'path': '/name',
'value': 'bay_example_B',
'op': 'replace'}]
response = self.app.patch_json('/v1/bays/%s' % c.get('uuid'),
params=params)
self.assertEqual(response.status_int, 200)
# Delete the bay we created
response = self.app.delete('/v1/bays/%s' % c.get('uuid'))