diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-03-12 02:46:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-03-12 02:46:11 +0000 |
| commit | fa4751edef2c12c4e28372659d39c8902f2e9990 (patch) | |
| tree | 5510a811162c2b6359c6c211cb58455893e860ef /nova/tests | |
| parent | 2cc409c6f0ae61b1c1833ce679b603d0369b42e8 (diff) | |
| parent | b5f75253048438891a8740a1ea4719e5f3208ccb (diff) | |
Merge "Sub in InstanceLimitExceeded in overLimit message"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/compute/test_servers.py | 19 | ||||
| -rw-r--r-- | nova/tests/api/openstack/fakes.py | 6 |
2 files changed, 25 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index 9d40d7eaa..2d3384dce 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -2068,6 +2068,25 @@ class ServersControllerCreateTest(test.TestCase): self.assertEqual(robj['Location'], selfhref) + def test_create_instance_above_quota(self): + fakes.stub_out_instance_quota(self.stubs, 0) + image_uuid = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77' + body = dict(server=dict( + name='server_test', imageRef=image_uuid, flavorRef=2, + metadata={'hello': 'world', 'open': 'stack'}, + personality={})) + req = fakes.HTTPRequest.blank('/v2/fake/servers') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + try: + server = self.controller.create(req, body).obj['server'] + fail('excepted quota to be exceeded') + except webob.exc.HTTPRequestEntityTooLarge as e: + code = {'code': 'InstanceLimitExceeded'} + self.assertEquals(e.explanation, + _('Quota exceeded: code=%(code)s') % code) + class TestServerCreateRequestXMLDeserializer(test.TestCase): diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 172a549ba..80f72aaea 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -153,6 +153,12 @@ def stub_out_rate_limiting(stubs): '__call__', fake_wsgi) +def stub_out_instance_quota(stubs, allowed): + def fake_allowed_instances(context, max_count, instance_type): + return allowed + stubs.Set(nova.quota, 'allowed_instances', fake_allowed_instances) + + def stub_out_networking(stubs): def get_my_ip(): return '127.0.0.1' |
