Fix QuotaClassSet and their tests
Some parameters of quota_class_set are not used in Nova v1.1/v2 API. And some items have wrong type and key name. QuotaClassSet class has id property originally. But 'id' comes from Nova API currently. So we can just use it as its id. This commit fixes and cleanups them. Change-Id: Ib963ff82e3107d7b78a3a63a2fc1cd6b6bbe47b0
This commit is contained in:
parent
1a20d2964d
commit
ee0401585d
novaclient
@ -1154,36 +1154,31 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
|
||||
def get_os_quota_class_sets_test(self, **kw):
|
||||
return (200, {}, {'quota_class_set': {
|
||||
'class_name': 'test',
|
||||
'metadata_items': [],
|
||||
'id': 'test',
|
||||
'metadata_items': 1,
|
||||
'injected_file_content_bytes': 1,
|
||||
'injected_file_path_bytes': 1,
|
||||
'volumes': 1,
|
||||
'gigabytes': 1,
|
||||
'ram': 1,
|
||||
'floating_ips': 1,
|
||||
'instances': 1,
|
||||
'injected_files': 1,
|
||||
'cores': 1,
|
||||
'keypairs': 1,
|
||||
'key_pairs': 1,
|
||||
'security_groups': 1,
|
||||
'security_group_rules': 1}})
|
||||
|
||||
def put_os_quota_class_sets_test(self, body, **kw):
|
||||
assert list(body) == ['quota_class_set']
|
||||
return (200, {}, {'quota_class_set': {
|
||||
'class_name': 'test',
|
||||
'metadata_items': [],
|
||||
'metadata_items': 1,
|
||||
'injected_file_content_bytes': 1,
|
||||
'injected_file_path_bytes': 1,
|
||||
'volumes': 2,
|
||||
'gigabytes': 1,
|
||||
'ram': 1,
|
||||
'floating_ips': 1,
|
||||
'instances': 1,
|
||||
'injected_files': 1,
|
||||
'cores': 1,
|
||||
'keypairs': 1,
|
||||
'key_pairs': 1,
|
||||
'security_groups': 1,
|
||||
'security_group_rules': 1}})
|
||||
|
||||
@ -1191,18 +1186,15 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
body, **kw):
|
||||
assert list(body) == ['quota_class_set']
|
||||
return (200, {}, {'quota_class_set': {
|
||||
'class_name': '97f4c221bff44578b0300df4ef119353',
|
||||
'metadata_items': [],
|
||||
'metadata_items': 1,
|
||||
'injected_file_content_bytes': 1,
|
||||
'injected_file_path_bytes': 1,
|
||||
'volumes': 2,
|
||||
'gigabytes': 1,
|
||||
'ram': 1,
|
||||
'floating_ips': 1,
|
||||
'instances': 1,
|
||||
'injected_files': 1,
|
||||
'cores': 1,
|
||||
'keypairs': 1,
|
||||
'key_pairs': 1,
|
||||
'security_groups': 1,
|
||||
'security_group_rules': 1}})
|
||||
|
||||
|
@ -29,14 +29,14 @@ class QuotaClassSetsTest(utils.TestCase):
|
||||
|
||||
def test_update_quota(self):
|
||||
q = cs.quota_classes.get('test')
|
||||
q.update(volumes=2)
|
||||
q.update(cores=2)
|
||||
cs.assert_called('PUT', '/os-quota-class-sets/test')
|
||||
|
||||
def test_refresh_quota(self):
|
||||
q = cs.quota_classes.get('test')
|
||||
q2 = cs.quota_classes.get('test')
|
||||
self.assertEqual(q.volumes, q2.volumes)
|
||||
q2.volumes = 0
|
||||
self.assertNotEqual(q.volumes, q2.volumes)
|
||||
self.assertEqual(q.cores, q2.cores)
|
||||
q2.cores = 0
|
||||
self.assertNotEqual(q.cores, q2.cores)
|
||||
q2.get()
|
||||
self.assertEqual(q.volumes, q2.volumes)
|
||||
self.assertEqual(q.cores, q2.cores)
|
||||
|
@ -18,15 +18,8 @@ from novaclient import base
|
||||
|
||||
class QuotaClassSet(base.Resource):
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""QuotaClassSet does not have a 'id' attribute but base.Resource
|
||||
needs it to self-refresh and QuotaSet is indexed by class_name.
|
||||
"""
|
||||
return self.class_name
|
||||
|
||||
def update(self, *args, **kwargs):
|
||||
return self.manager.update(self.class_name, *args, **kwargs)
|
||||
return self.manager.update(self.id, *args, **kwargs)
|
||||
|
||||
|
||||
class QuotaClassSetManager(base.Manager):
|
||||
|
Loading…
x
Reference in New Issue
Block a user