Merge "Revice REST APIs"
This commit is contained in:
commit
9b377614c7
@ -60,7 +60,7 @@ def baymodel_create(request, **kwargs):
|
||||
else:
|
||||
raise exceptions.InvalidAttribute(
|
||||
"Key must be in %s" % ",".join(BAYMODEL_CREATE_ATTRS))
|
||||
return magnumclient(request).baymodels.create(args)
|
||||
return magnumclient(request).baymodels.create(**args)
|
||||
|
||||
|
||||
def baymodel_delete(request, id):
|
||||
|
@ -63,8 +63,8 @@ class BayModels(generic.View):
|
||||
"""
|
||||
new_baymodel = magnum.baymodel_create(request, **request.DATA)
|
||||
return rest_utils.CreatedResponse(
|
||||
'/api/containers/baymodel/%s' % new_baymodel['uuid'],
|
||||
new_baymodel)
|
||||
'/api/containers/baymodel/%s' % new_baymodel.uuid,
|
||||
new_baymodel.to_dict())
|
||||
|
||||
|
||||
@urls.register
|
||||
@ -137,4 +137,5 @@ class Containers(generic.View):
|
||||
"""
|
||||
container = magnum.container_create(request, **request.DATA)
|
||||
return rest_utils.CreatedResponse(
|
||||
'/api/containers/container/%s' % container['uuid'], container)
|
||||
'/api/containers/container/%s' % container.uuid,
|
||||
container.to_dict())
|
||||
|
@ -39,17 +39,18 @@ class MagnumRestTestCase(test.TestCase):
|
||||
|
||||
@mock.patch.object(magnum, 'magnum')
|
||||
def test_baymodel_create(self, client):
|
||||
test_baymodel = TEST.baymodels.first()
|
||||
test_body = json.dumps(test_baymodel)
|
||||
test_baymodels = mock_resource(TEST.baymodels.list())
|
||||
test_bmodel = test_baymodels[0]
|
||||
test_body = json.dumps(test_bmodel.to_dict())
|
||||
request = self.mock_rest_request(body=test_body)
|
||||
client.baymodel_create.return_value = test_baymodel
|
||||
client.baymodel_create.return_value = test_bmodel
|
||||
response = magnum.BayModels().post(request)
|
||||
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'],
|
||||
'/api/containers/baymodel/%s' % test_baymodel['uuid'])
|
||||
'/api/containers/baymodel/%s' % test_bmodel.uuid)
|
||||
client.baymodel_create.assert_called_once_with(request,
|
||||
**test_baymodel)
|
||||
**test_bmodel.to_dict())
|
||||
|
||||
@mock.patch.object(magnum, 'magnum')
|
||||
def test_baymodel_delete(self, client):
|
||||
@ -117,16 +118,18 @@ class MagnumRestTestCase(test.TestCase):
|
||||
|
||||
@mock.patch.object(magnum, 'magnum')
|
||||
def test_container_create(self, client):
|
||||
test_cont = TEST.magnum_containers.first()
|
||||
test_body = json.dumps(test_cont)
|
||||
test_conts = mock_resource(TEST.magnum_containers.list())
|
||||
test_cont = test_conts[0]
|
||||
test_body = json.dumps(test_cont.to_dict())
|
||||
request = self.mock_rest_request(body=test_body)
|
||||
client.container_create.return_value = test_cont
|
||||
response = magnum.Containers().post(request)
|
||||
|
||||
self.assertStatusCode(response, 201)
|
||||
self.assertEqual(response['location'],
|
||||
'/api/containers/container/%s' % test_cont['uuid'])
|
||||
client.container_create.assert_called_once_with(request, **test_cont)
|
||||
'/api/containers/container/%s' % test_cont.uuid)
|
||||
client.container_create.assert_called_once_with(request,
|
||||
**test_cont.to_dict())
|
||||
|
||||
@mock.patch.object(magnum, 'magnum')
|
||||
def test_container_delete(self, client):
|
||||
|
Loading…
x
Reference in New Issue
Block a user