updating quotas and tests with the format which recently landed in nova
This commit is contained in:
parent
5a53520698
commit
0476cb6b75
@ -58,4 +58,4 @@ class QuotaSetManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
def defaults(self, tenant_id):
|
def defaults(self, tenant_id):
|
||||||
return self._get('/os-quota-sets/%s/defaults' % tenant_id,
|
return self._get('/os-quota-sets/%s/defaults' % tenant_id,
|
||||||
'quota_set_list')
|
'quota_set')
|
||||||
|
@ -34,9 +34,11 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
munged_url = url.strip('/').replace('/', '_').replace('.', '_')
|
munged_url = url.strip('/').replace('/', '_').replace('.', '_')
|
||||||
munged_url = munged_url.replace('-', '_')
|
munged_url = munged_url.replace('-', '_')
|
||||||
callback = "%s_%s" % (method.lower(), munged_url)
|
callback = "%s_%s" % (method.lower(), munged_url)
|
||||||
|
|
||||||
if not hasattr(self, callback):
|
if not hasattr(self, callback):
|
||||||
raise AssertionError('Called unknown API method: %s %s' % (method,
|
raise AssertionError('Called unknown API method: %s %s, '
|
||||||
url))
|
'expected fakes method name: %s' %
|
||||||
|
(method, url, callback))
|
||||||
|
|
||||||
# Note the call
|
# Note the call
|
||||||
self.callstack.append((method, url, kwargs.get('body', None)))
|
self.callstack.append((method, url, kwargs.get('body', None)))
|
||||||
@ -394,42 +396,47 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
return (202, r)
|
return (202, r)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Quotas
|
# Quotas
|
||||||
#
|
#
|
||||||
def get_os_quotas(self, *kw):
|
|
||||||
return (200, {'quota_set_list': [{
|
|
||||||
'tenant_id': 'test',
|
|
||||||
'metadata_items': [],
|
|
||||||
'injected_file_content_bytes': 1,
|
|
||||||
'volumes': 1,
|
|
||||||
'gigabytes': 1,
|
|
||||||
'ram': 1,
|
|
||||||
'floating_ips': 1,
|
|
||||||
'instances': 1,
|
|
||||||
'injected_files': 1,
|
|
||||||
'cores': 1,
|
|
||||||
}]})
|
|
||||||
|
|
||||||
def get_os_quotas_test(self, *kw):
|
def get_os_quota_sets_test(self, **kw):
|
||||||
return (200, {'quota_set': {
|
return (200, {'quota_set': {
|
||||||
'tenant_id': 'test',
|
'tenant_id': 'test',
|
||||||
'metadata_items': [],
|
'metadata_items': [],
|
||||||
'injected_file_content_bytes': 1,
|
'injected_file_content_bytes': 1,
|
||||||
'volumes': 1,
|
'volumes': 1,
|
||||||
'gigabytes': 1,
|
'gigabytes': 1,
|
||||||
'ram': 1,
|
'ram': 1,
|
||||||
'floating_ips': 1,
|
'floating_ips': 1,
|
||||||
'instances': 1,
|
'instances': 1,
|
||||||
'injected_files': 1,
|
'injected_files': 1,
|
||||||
'cores': 1,
|
'cores': 1}})
|
||||||
}})
|
|
||||||
|
|
||||||
def delete_os_quotas_test(self, **kw):
|
def get_os_quota_sets_test_defaults(self):
|
||||||
return (202, None)
|
return (200, {'quota_set': {
|
||||||
|
'tenant_id': 'test',
|
||||||
|
'metadata_items': [],
|
||||||
|
'injected_file_content_bytes': 1,
|
||||||
|
'volumes': 1,
|
||||||
|
'gigabytes': 1,
|
||||||
|
'ram': 1,
|
||||||
|
'floating_ips': 1,
|
||||||
|
'instances': 1,
|
||||||
|
'injected_files': 1,
|
||||||
|
'cores': 1}})
|
||||||
|
|
||||||
def put_os_quotas_test(self, body, **kw):
|
def put_os_quota_sets_test(self, body, **kw):
|
||||||
assert body.keys() == ['quota_set']
|
assert body.keys() == ['quota_set']
|
||||||
fakes.assert_has_keys(body['quota_set'],
|
fakes.assert_has_keys(body['quota_set'],
|
||||||
required=['tenant_id'])
|
required=['tenant_id'])
|
||||||
r = self.get_os_quotas_test()[1]
|
return (200, {'quota_set': {
|
||||||
return (200, r)
|
'tenant_id': 'test',
|
||||||
|
'metadata_items': [],
|
||||||
|
'injected_file_content_bytes': 1,
|
||||||
|
'volumes': 2,
|
||||||
|
'gigabytes': 1,
|
||||||
|
'ram': 1,
|
||||||
|
'floating_ips': 1,
|
||||||
|
'instances': 1,
|
||||||
|
'injected_files': 1,
|
||||||
|
'cores': 1}})
|
||||||
|
@ -22,22 +22,19 @@ from tests import utils
|
|||||||
cs = fakes.FakeClient()
|
cs = fakes.FakeClient()
|
||||||
|
|
||||||
|
|
||||||
class QuoatsTest(utils.TestCase):
|
class QuotaSetsTest(utils.TestCase):
|
||||||
def test_list_quotas(self):
|
|
||||||
qs = cs.quotas.list()
|
|
||||||
cs.assert_called('GET', '/os-quotas')
|
|
||||||
[self.assertTrue(isinstance(q, quotas.QuotaSet)) for q in qs]
|
|
||||||
|
|
||||||
def test_delete_quota(self):
|
def test_tenant_quotas_get(self):
|
||||||
q = cs.quotas.list()[0]
|
tenant_id = 'test'
|
||||||
q.delete()
|
qs = cs.quotas.get(tenant_id)
|
||||||
cs.assert_called('DELETE', '/os-quotas/test')
|
cs.assert_called('GET', '/os-quota-sets/%s' % tenant_id)
|
||||||
cs.quotas.delete('test')
|
|
||||||
cs.assert_called('DELETE', '/os-quotas/test')
|
def test_tenant_quotas_defaults(self):
|
||||||
cs.quotas.delete(q)
|
tenant_id = 'test'
|
||||||
cs.assert_called('DELETE', '/os-quotas/test')
|
q = cs.quotas.defaults(tenant_id)
|
||||||
|
cs.assert_called('GET', '/os-quota-sets/%s/defaults' % tenant_id)
|
||||||
|
|
||||||
def test_update_quota(self):
|
def test_update_quota(self):
|
||||||
q = cs.quotas.list()[0]
|
q = cs.quotas.get('test')
|
||||||
q.update(volumes=2)
|
q.update(volumes=2)
|
||||||
cs.assert_called('PUT', '/os-quotas/test')
|
cs.assert_called('PUT', '/os-quota-sets/test')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user