From 5d8735e15875c9d923046256af5a3c5f1a130e28 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Tue, 15 Sep 2015 10:16:11 -0700 Subject: [PATCH] Set expected HTTP codes for create and delete Our API tests have HTTP code assertions that our controller was not honoring in the create and delete cases. Change-Id: I3b00348c854b5d887d74c115d06984222f20ccc1 --- neutron/pecan_wsgi/controllers/root.py | 3 +++ neutron/tests/functional/pecan_wsgi/test_functional.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/neutron/pecan_wsgi/controllers/root.py b/neutron/pecan_wsgi/controllers/root.py index b277ce28f..0162b7bcd 100644 --- a/neutron/pecan_wsgi/controllers/root.py +++ b/neutron/pecan_wsgi/controllers/root.py @@ -138,6 +138,7 @@ class CollectionsController(object): @when(index, method='POST') def post(self, *args, **kwargs): # TODO(kevinbenton): emulated bulk! + pecan.response.status = 201 if request.bulk: method = 'create_%s_bulk' % request.resource_type else: @@ -172,5 +173,7 @@ class ItemController(object): @when(index, method='DELETE') def delete(self): + # TODO(kevinbenton): setting code could be in a decorator + pecan.response.status = 204 deleter = getattr(request.plugin, 'delete_%s' % request.resource_type) return deleter(request.context, self.item) diff --git a/neutron/tests/functional/pecan_wsgi/test_functional.py b/neutron/tests/functional/pecan_wsgi/test_functional.py index 8e4b135d3..a3666277f 100644 --- a/neutron/tests/functional/pecan_wsgi/test_functional.py +++ b/neutron/tests/functional/pecan_wsgi/test_functional.py @@ -78,7 +78,7 @@ class TestV2Controller(PecanFunctionalTest): 'admin_state_up': True, 'tenant_id': 'tenid'}}, headers={'X-Tenant-Id': 'tenid'}) - self.assertEqual(response.status_int, 200) + self.assertEqual(response.status_int, 201) def test_put(self): response = self.app.put_json('/v2.0/ports/%s.json' % self.port['id'], @@ -89,7 +89,7 @@ class TestV2Controller(PecanFunctionalTest): def test_delete(self): response = self.app.delete('/v2.0/ports/%s.json' % self.port['id'], headers={'X-Tenant-Id': 'tenid'}) - self.assertEqual(response.status_int, 200) + self.assertEqual(response.status_int, 204) def test_plugin_initialized(self): self.assertIsNotNone(manager.NeutronManager._instance) -- 2.45.2