From 1767e0ae9595003c22facc86e590b7c9b1ed6a75 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 21 Feb 2012 21:10:57 -0800 Subject: Return 40x for flavor.create duplicate. * Fixes bug 938194 * Return error 409 instead of 400 Change-Id: Ia3c597dc996d88e7026f76d1104058259c96301c --- .../compute/contrib/test_flavor_manage.py | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py b/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py index e825aa4bd..8a18c1ab2 100644 --- a/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py +++ b/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py @@ -115,3 +115,30 @@ class FlavorManageTest(test.TestCase): body = json.loads(res.body) for key in expected["flavor"]: self.assertEquals(body["flavor"][key], expected["flavor"][key]) + + def test_instance_type_exists_exception_returns_409(self): + expected = { + "flavor": { + "name": "test", + "ram": 512, + "vcpus": 2, + "disk": 1, + "OS-FLV-EXT-DATA:ephemeral": 1, + "id": 1235, + "swap": 512, + "rxtx_factor": 1, + } + } + + def fake_create(name, memory_mb, vcpus, root_gb, ephemeral_gb, + flavorid, swap, rxtx_factor): + raise exception.InstanceTypeExists() + + self.stubs.Set(instance_types, "create", fake_create) + url = '/v2/fake/flavors' + req = webob.Request.blank(url) + req.headers['Content-Type'] = 'application/json' + req.method = 'POST' + req.body = json.dumps(expected) + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(res.status_int, 409) -- cgit