diff --git a/novaclient/v1_1/quotas.py b/novaclient/v1_1/quotas.py index 884f3a25b..9c5100866 100644 --- a/novaclient/v1_1/quotas.py +++ b/novaclient/v1_1/quotas.py @@ -58,4 +58,4 @@ class QuotaSetManager(base.ManagerWithFind): def defaults(self, tenant_id): return self._get('/os-quota-sets/%s/defaults' % tenant_id, - 'quota_set_list') + 'quota_set') diff --git a/tests/v1_1/fakes.py b/tests/v1_1/fakes.py index f7ada1b30..f3a04a315 100644 --- a/tests/v1_1/fakes.py +++ b/tests/v1_1/fakes.py @@ -34,9 +34,11 @@ class FakeHTTPClient(base_client.HTTPClient): munged_url = url.strip('/').replace('/', '_').replace('.', '_') munged_url = munged_url.replace('-', '_') callback = "%s_%s" % (method.lower(), munged_url) + if not hasattr(self, callback): - raise AssertionError('Called unknown API method: %s %s' % (method, - url)) + raise AssertionError('Called unknown API method: %s %s, ' + 'expected fakes method name: %s' % + (method, url, callback)) # Note the call self.callstack.append((method, url, kwargs.get('body', None))) @@ -394,42 +396,47 @@ class FakeHTTPClient(base_client.HTTPClient): 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): - 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 get_os_quota_sets_test(self, **kw): + 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 delete_os_quotas_test(self, **kw): - return (202, None) + def get_os_quota_sets_test_defaults(self): + 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'] fakes.assert_has_keys(body['quota_set'], required=['tenant_id']) - r = self.get_os_quotas_test()[1] - return (200, r) + return (200, {'quota_set': { + '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}}) diff --git a/tests/v1_1/test_quotas.py b/tests/v1_1/test_quotas.py index 073a9241f..254850240 100644 --- a/tests/v1_1/test_quotas.py +++ b/tests/v1_1/test_quotas.py @@ -22,22 +22,19 @@ from tests import utils cs = fakes.FakeClient() -class QuoatsTest(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] +class QuotaSetsTest(utils.TestCase): - def test_delete_quota(self): - q = cs.quotas.list()[0] - q.delete() - cs.assert_called('DELETE', '/os-quotas/test') - cs.quotas.delete('test') - cs.assert_called('DELETE', '/os-quotas/test') - cs.quotas.delete(q) - cs.assert_called('DELETE', '/os-quotas/test') + def test_tenant_quotas_get(self): + tenant_id = 'test' + qs = cs.quotas.get(tenant_id) + cs.assert_called('GET', '/os-quota-sets/%s' % tenant_id) + + def test_tenant_quotas_defaults(self): + tenant_id = 'test' + q = cs.quotas.defaults(tenant_id) + cs.assert_called('GET', '/os-quota-sets/%s/defaults' % tenant_id) def test_update_quota(self): - q = cs.quotas.list()[0] + q = cs.quotas.get('test') q.update(volumes=2) - cs.assert_called('PUT', '/os-quotas/test') + cs.assert_called('PUT', '/os-quota-sets/test')