2013-03-13 18:09:17 -04:00
|
|
|
# Copyright 2011 OpenStack Foundation
|
2011-08-09 13:12:09 -07:00
|
|
|
# All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2013-05-18 07:26:28 -07:00
|
|
|
from novaclient.tests import utils
|
|
|
|
from novaclient.tests.v1_1 import fakes
|
2011-08-08 14:48:07 -07:00
|
|
|
|
|
|
|
|
2011-08-16 13:36:45 -07:00
|
|
|
class QuotaSetsTest(utils.TestCase):
|
2013-12-11 17:49:25 +10:30
|
|
|
def setUp(self):
|
|
|
|
super(QuotaSetsTest, self).setUp()
|
|
|
|
self.cs = self._get_fake_client()
|
|
|
|
|
|
|
|
def _get_fake_client(self):
|
|
|
|
return fakes.FakeClient()
|
2011-08-16 13:36:45 -07:00
|
|
|
|
|
|
|
def test_tenant_quotas_get(self):
|
|
|
|
tenant_id = 'test'
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.quotas.get(tenant_id)
|
|
|
|
self.cs.assert_called('GET', '/os-quota-sets/%s' % tenant_id)
|
2011-08-16 13:36:45 -07:00
|
|
|
|
2013-07-30 10:18:59 +08:00
|
|
|
def test_user_quotas_get(self):
|
|
|
|
tenant_id = 'test'
|
|
|
|
user_id = 'fake_user'
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.quotas.get(tenant_id, user_id=user_id)
|
2013-07-30 10:18:59 +08:00
|
|
|
url = '/os-quota-sets/%s?user_id=%s' % (tenant_id, user_id)
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.assert_called('GET', url)
|
2013-07-30 10:18:59 +08:00
|
|
|
|
2011-08-16 13:36:45 -07:00
|
|
|
def test_tenant_quotas_defaults(self):
|
2013-03-05 01:55:30 +00:00
|
|
|
tenant_id = '97f4c221bff44578b0300df4ef119353'
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.quotas.defaults(tenant_id)
|
|
|
|
self.cs.assert_called('GET', '/os-quota-sets/%s/defaults' % tenant_id)
|
2011-08-08 14:48:07 -07:00
|
|
|
|
2013-06-15 10:07:49 +08:00
|
|
|
def test_force_update_quota(self):
|
2013-12-11 17:49:25 +10:30
|
|
|
q = self.cs.quotas.get('97f4c221bff44578b0300df4ef119353')
|
2013-06-15 10:07:49 +08:00
|
|
|
q.update(cores=2, force=True)
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.assert_called(
|
2013-06-15 10:07:49 +08:00
|
|
|
'PUT', '/os-quota-sets/97f4c221bff44578b0300df4ef119353',
|
|
|
|
{'quota_set': {'force': True,
|
|
|
|
'cores': 2,
|
|
|
|
'tenant_id': '97f4c221bff44578b0300df4ef119353'}})
|
|
|
|
|
2013-06-03 17:33:17 +05:30
|
|
|
def test_quotas_delete(self):
|
|
|
|
tenant_id = 'test'
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.quotas.delete(tenant_id)
|
|
|
|
self.cs.assert_called('DELETE', '/os-quota-sets/%s' % tenant_id)
|
2013-07-30 10:18:59 +08:00
|
|
|
|
|
|
|
def test_user_quotas_delete(self):
|
|
|
|
tenant_id = 'test'
|
|
|
|
user_id = 'fake_user'
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.quotas.delete(tenant_id, user_id=user_id)
|
2013-07-30 10:18:59 +08:00
|
|
|
url = '/os-quota-sets/%s?user_id=%s' % (tenant_id, user_id)
|
2013-12-11 17:49:25 +10:30
|
|
|
self.cs.assert_called('DELETE', url)
|