From 80d355a7e360d2558c8b99ff4381b56284ce29d4 Mon Sep 17 00:00:00 2001 From: Chris Yeoh Date: Tue, 23 Jul 2013 11:57:55 +0930 Subject: [PATCH] Fixes for v3 API servers tests Fixes some v3 API servers unittests to correctly use the fake v3 wsgi_app rather than the v2 one. Also fixes xml in test_update_server_invalid_xml_raises_lookup so that it will only cause a LookupError rather than a LookupError and an ExpatError as the latter will mask the failure of the former to be raised. Also adds checking of the actual error message returned for the two unittests affected. partially implements blueprint v3-api-unittests Change-Id: I2abf8875e2cc3feda14f93d8c1e7a88c5a278ca8 --- .../openstack/compute/plugins/v3/test_servers.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_servers.py b/nova/tests/api/openstack/compute/plugins/v3/test_servers.py index fa46bee71c..498cacbd5c 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_servers.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_servers.py @@ -1090,19 +1090,22 @@ class ServersControllerTest(ControllerTest): self.assertEqual(res_dict['server']['accessIPv6'], 'beef::123') def test_update_server_invalid_xml_raises_lookup(self): - req = fakes.HTTPRequestV3.blank('/servers/%s' % FAKE_UUID) + req = webob.Request.blank('/v3/servers/%s' % FAKE_UUID) req.method = 'PUT' req.content_type = 'application/xml' #xml request which raises LookupError req.body = """ """ - res = req.get_response(fakes.wsgi_app()) + key="Label">""" + res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 400) + res_dict = jsonutils.loads(res.body) + self.assertEqual(res_dict['badRequest']['message'], + "Malformed request body") def test_update_server_invalid_xml_raises_expat(self): - req = fakes.HTTPRequestV3.blank('/servers/%s' % FAKE_UUID) + req = webob.Request.blank('/v3/servers/%s' % FAKE_UUID) req.method = 'PUT' req.content_type = 'application/xml' #xml request which raises ExpatError @@ -1110,8 +1113,11 @@ class ServersControllerTest(ControllerTest): """ - res = req.get_response(fakes.wsgi_app()) + res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 400) + res_dict = jsonutils.loads(res.body) + self.assertEqual(res_dict['badRequest']['message'], + "Malformed request body") def test_update_server_name(self): self.stubs.Set(db, 'instance_get',