summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/v2/test_quotas.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/tests/unit/v2/test_quotas.py')
-rw-r--r--novaclient/tests/unit/v2/test_quotas.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_quotas.py b/novaclient/tests/unit/v2/test_quotas.py
new file mode 100644
index 0000000..43f8ce1
--- /dev/null
+++ b/novaclient/tests/unit/v2/test_quotas.py
@@ -0,0 +1,62 @@
1# Copyright 2011 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from novaclient.tests.unit.fixture_data import client
17from novaclient.tests.unit.fixture_data import quotas as data
18from novaclient.tests.unit import utils
19
20
21class QuotaSetsTest(utils.FixturedTestCase):
22
23 client_fixture_class = client.V1
24 data_fixture_class = data.V1
25
26 def test_tenant_quotas_get(self):
27 tenant_id = 'test'
28 self.cs.quotas.get(tenant_id)
29 self.assert_called('GET', '/os-quota-sets/%s' % tenant_id)
30
31 def test_user_quotas_get(self):
32 tenant_id = 'test'
33 user_id = 'fake_user'
34 self.cs.quotas.get(tenant_id, user_id=user_id)
35 url = '/os-quota-sets/%s?user_id=%s' % (tenant_id, user_id)
36 self.assert_called('GET', url)
37
38 def test_tenant_quotas_defaults(self):
39 tenant_id = '97f4c221bff44578b0300df4ef119353'
40 self.cs.quotas.defaults(tenant_id)
41 self.assert_called('GET', '/os-quota-sets/%s/defaults' % tenant_id)
42
43 def test_force_update_quota(self):
44 q = self.cs.quotas.get('97f4c221bff44578b0300df4ef119353')
45 q.update(cores=2, force=True)
46 self.assert_called(
47 'PUT', '/os-quota-sets/97f4c221bff44578b0300df4ef119353',
48 {'quota_set': {'force': True,
49 'cores': 2,
50 'tenant_id': '97f4c221bff44578b0300df4ef119353'}})
51
52 def test_quotas_delete(self):
53 tenant_id = 'test'
54 self.cs.quotas.delete(tenant_id)
55 self.assert_called('DELETE', '/os-quota-sets/%s' % tenant_id)
56
57 def test_user_quotas_delete(self):
58 tenant_id = 'test'
59 user_id = 'fake_user'
60 self.cs.quotas.delete(tenant_id, user_id=user_id)
61 url = '/os-quota-sets/%s?user_id=%s' % (tenant_id, user_id)
62 self.assert_called('DELETE', url)