Merge "Fix Setting Quotas in Neutron"

This commit is contained in:
Jenkins 2017-01-24 15:52:36 +00:00 committed by Gerrit Code Review
commit 1476f3b2af
3 changed files with 24 additions and 0 deletions

View File

@ -58,6 +58,17 @@ class Quota(resource.Resource):
#: The maximum amount of security groups you can create. *Type: int*
security_groups = resource.Body('security_group', type=int)
def _prepare_request(self, requires_id=True, prepend_key=False):
_request = super(Quota, self)._prepare_request(requires_id,
prepend_key)
if self.resource_key in _request.body:
_body = _request.body[self.resource_key]
else:
_body = _request.body
if 'id' in _body:
del _body['id']
return _request
class QuotaDefault(Quota):
base_path = '/quotas/%(project)s/default'

View File

@ -27,3 +27,10 @@ class TestQuota(base.BaseFunctionalTest):
self.assertIn('security_group', qot)
self.assertIn('subnetpool', qot)
self.assertIn('rbac_policy', qot)
def test_set(self):
attrs = {'network': 123456789}
self.conn.network.update_quota(**attrs)
quota_list = self.conn.network.get_quota()
for quota in quota_list:
self.assertIn('123456789', quota)

View File

@ -67,6 +67,12 @@ class TestQuota(testtools.TestCase):
self.assertEqual(EXAMPLE['l7policy'], sot.l7_policies)
self.assertEqual(EXAMPLE['pool'], sot.pools)
def test_prepare_request(self):
body = {'id': 'ABCDEFGH', 'network': '12345'}
quota_obj = quota.Quota(**body)
response = quota_obj._prepare_request()
self.assertNotIn('id', response)
class TestQuotaDefault(testtools.TestCase):