Fix incorrect argument position in DbQuotaDriver

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
This commit is contained in:
Tianpeng Wang
2013-11-26 13:10:40 +00:00
parent 55524d8f1d
commit 1447b8117b
2 changed files with 23 additions and 1 deletions

View File

@@ -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."""

View File

@@ -977,6 +977,28 @@ class DbQuotaDriverTestCase(test.TestCase):
),
))
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')