Example #1
0
 def append_master(self, uri, orm=ORM_SQLALCHEMY, **kwargs):
     if len(self._master_engines) >= self._master_limit:
         raise DBClusterException(
             "The master engine has already "
             "configured.  Cowardly refusing to replace it.")
     if orm == self.ORM_SQLALCHEMY:
         self._master_engines.append(
             (ds.SQLAlchemyEngineContainer(uri, **kwargs), orm))
     else:
         raise ValueError("Unknown orm type: {}".format(orm))
Example #2
0
 def append_slave(self, uri, orm=ORM_SQLALCHEMY, **kwargs):
     if orm == self.ORM_SQLALCHEMY:
         self._slave_engines.append(
             (ds.SQLAlchemyEngineContainer(uri, slave=True, **kwargs), orm))
     else:
         raise ValueError("Unknown orm type: {}".format(orm))
Example #3
0
 def test_destroy(self):
     out = ds.SQLAlchemyEngineContainer('sqlite:///:memory:')
     out.destroy()
     assert True
Example #4
0
 def test_get_controlled_session(self):
     out = ds.SQLAlchemyEngineContainer('sqlite:///:memory:')
     with out.get_controlled_session() as session:
         assert isinstance(session, sqlalchemy.orm.session.Session)
Example #5
0
 def test_get_new_session(self):
     out = ds.SQLAlchemyEngineContainer('sqlite:///:memory:')
     session = out.get_new_session()
     assert isinstance(session, sqlalchemy.orm.session.Session)
Example #6
0
 def test__init__(self):
     out = ds.SQLAlchemyEngineContainer('sqlite:///:memory:')
     assert isinstance(out, ds.SQLAlchemyEngineContainer)