fix fakeldap so it can use redis keeper

This commit is contained in:
Vishvananda Ishaya
2010-06-24 04:11:59 +01:00
committed by andy
parent 70b9d6b2df
commit d171bed950
3 changed files with 24 additions and 23 deletions

View File

@@ -40,7 +40,7 @@ def initialize(uri):
class FakeLDAP(object):
def __init__(self, _uri):
self.keeper = datastore.SqliteKeeper('fakeldap') #Redis keeper never works here...
self.keeper = datastore.Keeper('fakeldap')
if self.keeper['objects'] is None:
self.keeper['objects'] = {}

View File

@@ -53,7 +53,7 @@ def skip_if_fake(f):
class TrialTestCase(trial_unittest.TestCase):
flush_db = True
def setUp(self):
super(TrialTestCase, self).setUp()
@@ -62,11 +62,6 @@ class TrialTestCase(trial_unittest.TestCase):
self.mox = mox.Mox()
self.stubs = stubout.StubOutForTesting()
self.flag_overrides = {}
self.flags(redis_db=8)
if self.flush_db:
logging.info("Flushing redis datastore")
r = datastore.Redis.instance()
r.flushdb()
def tearDown(self):
super(TrialTestCase, self).tearDown()
@@ -124,8 +119,6 @@ class BaseTestCase(TrialTestCase):
if FLAGS.fake_rabbit:
fakerabbit.reset_all()
self.tear_down()
r = datastore.Redis.instance()
r.flushdb()
def _waitForTest(self, timeout=60):
""" Push the ioloop along to wait for our test to complete. """

View File

@@ -60,6 +60,8 @@ from nova.tests.validator_unittest import *
FLAGS = flags.FLAGS
flags.DEFINE_bool('flush_db', True,
'Flush the database before running fake tests')
if __name__ == '__main__':
OptionsClass = twistd.WrapTwistedOptions(trial_script.Options)
@@ -71,6 +73,12 @@ if __name__ == '__main__':
# TODO(termie): these should make a call instead of doing work on import
if FLAGS.fake_tests:
from nova.tests.fake_flags import *
# use db 8 for fake tests
FLAGS.redis_db = 8
if FLAGS.flush_db:
logging.info("Flushing redis datastore")
r = datastore.Redis.instance()
r.flushdb()
else:
from nova.tests.real_flags import *