diff --git a/quantum/db/quota_db.py b/quantum/db/quota_db.py index 5ccf8adb77..eef09f2941 100644 --- a/quantum/db/quota_db.py +++ b/quantum/db/quota_db.py @@ -138,7 +138,7 @@ class DbQuotaDriver(object): # Grab and return the quotas (without usages) quotas = DbQuotaDriver.get_tenant_quotas( - context, sub_resources, context.tenant_id) + context, sub_resources, tenant_id) return dict((k, v) for k, v in quotas.items()) diff --git a/quantum/tests/unit/test_quota_ext.py b/quantum/tests/unit/test_quota_ext.py index 73cfc74f97..3b4315503f 100644 --- a/quantum/tests/unit/test_quota_ext.py +++ b/quantum/tests/unit/test_quota_ext.py @@ -9,9 +9,11 @@ from quantum.common import config from quantum.common import exceptions from quantum import context from quantum.db import api as db +from quantum.db import quota_db from quantum import manager from quantum.plugins.linuxbridge.db import l2network_db_v2 from quantum import quota +from quantum.tests import base from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_extensions from quantum.tests.unit import testlib_api @@ -341,3 +343,31 @@ class QuotaExtensionCfgTestCase(QuotaExtensionTestCase): class QuotaExtensionCfgTestCaseXML(QuotaExtensionCfgTestCase): fmt = 'xml' + + +class TestDbQuotaDriver(base.BaseTestCase): + """Test for quantum.db.quota_db.DbQuotaDriver.""" + + def test_get_tenant_quotas_arg(self): + """Call quantum.db.quota_db.DbQuotaDriver._get_quotas.""" + + driver = quota_db.DbQuotaDriver() + ctx = context.Context('', 'bar') + + foo_quotas = {'network': 5} + default_quotas = {'network': 10} + target_tenant = 'foo' + + with mock.patch.object(quota_db.DbQuotaDriver, + 'get_tenant_quotas', + return_value=foo_quotas) as get_tenant_quotas: + + quotas = driver._get_quotas(ctx, + target_tenant, + default_quotas, + ['network']) + + self.assertEqual(quotas, foo_quotas) + get_tenant_quotas.assert_called_once_with(ctx, + default_quotas, + target_tenant)