Pecan: Fix Shim status codes

Fix the status codes returned by the shim controller
to match the expectations of the API tests.

Closes-bug: #1567801
Change-Id: Ibfede6b6bc4ba24cf2b9e4ff5540c2249695252f
This commit is contained in:
Kevin Benton 2016-03-14 08:00:46 -07:00
parent 1019d2b1e5
commit 2e19107fe2
2 changed files with 8 additions and 3 deletions

View File

@ -74,6 +74,7 @@ class ShimItemController(NeutronPecanController):
def delete(self):
if not self.controller_delete:
pecan.abort(405)
pecan.response.status = 204
shim_request = ShimRequest(request.context['neutron_context'])
uri_identifiers = request.context['uri_identifiers']
return self.controller_delete(shim_request, self.item,
@ -100,6 +101,7 @@ class ShimCollectionsController(NeutronPecanController):
def create(self):
if not self.controller_create:
pecan.abort(405)
pecan.response.status = 201
shim_request = ShimRequest(request.context['neutron_context'])
uri_identifiers = request.context['uri_identifiers']
return self.controller_create(shim_request, request.json,

View File

@ -551,16 +551,19 @@ class TestL3AgentShimControllers(test_functional.PecanFunctionalTest):
def test_add_remove_l3_agent(self):
headers = {'X-Project-Id': 'tenid', 'X-Roles': 'admin'}
self.app.post_json(
response = self.app.post_json(
'/v2.0/agents/%s/l3-routers.json' % self.agent.id,
headers=headers, params={'router_id': self.router['id']})
self.assertEqual(201, response.status_int)
response = self.app.get(
'/v2.0/routers/%s/l3-agents.json' % self.router['id'],
headers=headers)
self.assertIn(self.agent.id,
[a['id'] for a in response.json['agents']])
self.app.delete('/v2.0/agents/%(a)s/l3-routers/%(n)s.json' % {
'a': self.agent.id, 'n': self.router['id']}, headers=headers)
response = self.app.delete(
'/v2.0/agents/%(a)s/l3-routers/%(n)s.json' % {
'a': self.agent.id, 'n': self.router['id']}, headers=headers)
self.assertEqual(204, response.status_int)
response = self.app.get(
'/v2.0/routers/%s/l3-agents.json' % self.router['id'],
headers=headers)