Merge pull request #236 from OpenKMIP/bug/fix-sqlite-backend-multithread

Fixing a bug with multithreading support with the SQLite backend
This commit is contained in:
Peter Hamilton 2016-12-17 15:22:25 -05:00 committed by GitHub
commit 6374f914a0
2 changed files with 16 additions and 1 deletions

View File

@ -98,7 +98,8 @@ class KmipEngine(object):
self._data_store = sqlalchemy.create_engine(
'sqlite:////tmp/pykmip.database',
echo=False
echo=False,
connect_args={'check_same_thread': False}
)
sqltypes.Base.metadata.create_all(self._data_store)
self._data_store_session_factory = sqlalchemy.orm.sessionmaker(

View File

@ -140,6 +140,20 @@ class TestKmipEngine(testtools.TestCase):
"""
engine.KmipEngine()
@mock.patch('sqlalchemy.create_engine')
def test_init_create_engine(self, create_engine_mock):
"""
Test that the right arguments are used to create the engine's SQLite
backend.
"""
engine.KmipEngine()
args = ("sqlite:////tmp/pykmip.database",)
fargs = {
'echo': False,
'connect_args': {'check_same_thread': False}
}
create_engine_mock.assert_called_once_with(*args, **fargs)
def test_load_operation_policies(self):
"""
Test that the KmipEngine can correctly load operation policies.