Made get_engine method module-private
This method is not accessed outside of this module so there is no need for it to be public. Encapsulation this method will allow us to improve connection creation. Change-Id: I59e13c61510a81904858e575c2f6f8989727026c
This commit is contained in:
@@ -67,7 +67,7 @@ class StorageBadAggregate(Exception):
|
||||
code = 400
|
||||
|
||||
|
||||
def get_engine(conf):
|
||||
def _get_engine(conf):
|
||||
"""Load the configured engine and return an instance."""
|
||||
if conf.database_connection:
|
||||
conf.set_override('connection', conf.database_connection,
|
||||
@@ -84,7 +84,7 @@ def get_engine(conf):
|
||||
|
||||
def get_connection(conf):
|
||||
"""Return an open connection to the database."""
|
||||
return get_engine(conf).get_connection(conf)
|
||||
return _get_engine(conf).get_connection(conf)
|
||||
|
||||
|
||||
class SampleFilter(object):
|
||||
|
||||
@@ -27,16 +27,16 @@ from ceilometer.storage import impl_log
|
||||
|
||||
class EngineTest(test.BaseTestCase):
|
||||
|
||||
def test_get_engine(self):
|
||||
def test_get_connection(self):
|
||||
conf = mock.Mock()
|
||||
conf.database.connection = 'log://localhost'
|
||||
engine = storage.get_engine(conf)
|
||||
self.assertIsInstance(engine, impl_log.LogStorage)
|
||||
engine = storage.get_connection(conf)
|
||||
self.assertIsInstance(engine, impl_log.Connection)
|
||||
|
||||
def test_get_engine_no_such_engine(self):
|
||||
def test_get_connection_no_such_engine(self):
|
||||
conf = mock.Mock()
|
||||
conf.database.connection = 'no-such-engine://localhost'
|
||||
try:
|
||||
storage.get_engine(conf)
|
||||
storage.get_connection(conf)
|
||||
except RuntimeError as err:
|
||||
self.assertIn('no-such-engine', unicode(err))
|
||||
Reference in New Issue
Block a user