Skip to content

Commit

Permalink
Fix incorrect argument position in DbQuotaDriver
Browse files Browse the repository at this point in the history
The prototype of db.quota_get is:
`quota_get(context, project_id, resource, user_id=None)`
However, in DbQuotaDriver::get_by_project_and_user(), the `user_id`
is incorrectly used as a positional argument.

Closes-Bug: #1255035

Change-Id: I5b6a4c59efe6d9bdc8380e50b7f7c1ff0d2029b1
  • Loading branch information
timonwong committed Nov 26, 2013
1 parent 55524d8 commit 1447b81
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nova/quota.py
Expand Up @@ -97,7 +97,7 @@ class DbQuotaDriver(object):
def get_by_project_and_user(self, context, project_id, user_id, resource):
"""Get a specific quota by project and user."""

return db.quota_get(context, project_id, user_id, resource)
return db.quota_get(context, project_id, resource, user_id=user_id)

def get_by_project(self, context, project_id, resource):
"""Get a specific quota by project."""
Expand Down
22 changes: 22 additions & 0 deletions nova/tests/test_quota.py
Expand Up @@ -977,6 +977,28 @@ def test_get_user_quotas(self):
),
))

def _stub_get_by_project_and_user_specific(self):
def fake_quota_get(context, project_id, resource, user_id=None):
self.calls.append('quota_get')
self.assertEqual(project_id, 'test_project')
self.assertEqual(user_id, 'fake_user')
self.assertEqual(resource, 'test_resource')
return dict(
test_resource=dict(in_use=20, reserved=10),
)
self.stubs.Set(db, 'quota_get', fake_quota_get)

def test_get_by_project_and_user(self):
self._stub_get_by_project_and_user_specific()
result = self.driver.get_by_project_and_user(
FakeContext('test_project', 'test_class'),
'test_project', 'fake_user', 'test_resource')

self.assertEqual(self.calls, ['quota_get'])
self.assertEqual(result, dict(
test_resource=dict(in_use=20, reserved=10),
))

def _stub_get_by_project(self):
def fake_qgabp(context, project_id):
self.calls.append('quota_get_all_by_project')
Expand Down

0 comments on commit 1447b81

Please sign in to comment.