Merge "TestTrackedResource: register core plugin in directory"

This commit is contained in:
Jenkins 2017-03-31 20:12:59 +00:00 committed by Gerrit Code Review
commit 2a819bd39a
1 changed files with 5 additions and 12 deletions

View File

@ -60,7 +60,7 @@ class TestResource(base.DietTestCase):
self.assertEqual(-1, res.default) self.assertEqual(-1, res.default)
class TestTrackedResource(testlib_api.SqlTestCaseLight): class TestTrackedResource(testlib_api.SqlTestCase):
def _add_data(self, tenant_id=None): def _add_data(self, tenant_id=None):
session = db_api.get_writer_session() session = db_api.get_writer_session()
@ -91,31 +91,24 @@ class TestTrackedResource(testlib_api.SqlTestCaseLight):
session.add(item) session.add(item)
def setUp(self): def setUp(self):
base.BaseTestCase.config_parse() super(TestTrackedResource, self).setUp()
cfg.CONF.register_opts(meh_quota_opts, 'QUOTAS') self.setup_coreplugin(DB_PLUGIN_KLASS)
cfg.CONF.set_override("core_plugin", DB_PLUGIN_KLASS)
self.addCleanup(cfg.CONF.reset)
self.resource = 'meh' self.resource = 'meh'
self.other_resource = 'othermeh' self.other_resource = 'othermeh'
self.tenant_id = 'meh' self.tenant_id = 'meh'
self.context = context.Context( self.context = context.Context(
user_id='', tenant_id=self.tenant_id, is_admin=False) user_id='', tenant_id=self.tenant_id, is_admin=False)
super(TestTrackedResource, self).setUp()
def _register_events(self, res):
res.register_events()
self.addCleanup(res.unregister_events)
def _create_resource(self): def _create_resource(self):
res = resource.TrackedResource( res = resource.TrackedResource(
self.resource, test_quota.MehModel, meh_quota_flag) self.resource, test_quota.MehModel, meh_quota_flag)
self._register_events(res) res.register_events()
return res return res
def _create_other_resource(self): def _create_other_resource(self):
res = resource.TrackedResource( res = resource.TrackedResource(
self.other_resource, test_quota.OtherMehModel, meh_quota_flag) self.other_resource, test_quota.OtherMehModel, meh_quota_flag)
self._register_events(res) res.register_events()
return res return res
def test_bulk_delete_protection(self): def test_bulk_delete_protection(self):