def setUp(self): super(TestDatabaseStore, self).setUp() self.driver = introspection_data.DatabaseStore() session = db.get_writer_session() with session.begin(): db.Node(uuid=self.node_info.uuid, state=istate.States.starting).save(session)
def test_get_writer_session(self, mock_cnxt_mgr): mock_cnxt = mock_cnxt_mgr.return_value mock_sess_maker = mock_cnxt.writer.get_sessionmaker.return_value session = db.get_writer_session() mock_sess_maker.assert_called_once_with() self.assertEqual(mock_sess_maker.return_value, session)
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ session = db.get_writer_session() with session.connection() as connection: context.configure(connection=connection, target_metadata=target_metadata) with context.begin_transaction(): context.run_migrations()
def setUp(self): super(BaseTest, self).setUp() if not self.IS_FUNCTIONAL: self.init_test_conf() self.session = db.get_writer_session() engine = self.session.get_bind() db.Base.metadata.create_all(engine) engine.connect() self.addCleanup(engine.dispose) plugins_base.reset() node_cache._SEMAPHORES = lockutils.Semaphores() patch = mock.patch.object(i18n, '_', lambda s: s) patch.start() # 'p=patch' magic is due to how closures work self.addCleanup(lambda p=patch: p.stop()) utils._EXECUTOR = futurist.SynchronousExecutor(green=True)
def setUp(self): super(BaseTest, self).setUp() if not self.IS_FUNCTIONAL: self.init_test_conf() self.session = db.get_writer_session() engine = self.session.get_bind() db.Base.metadata.create_all(engine) engine.connect() self.addCleanup(engine.dispose) plugins_base._HOOKS_MGR = None node_cache._SEMAPHORES = lockutils.Semaphores() patch = mock.patch.object(i18n, '_', lambda s: s) patch.start() # 'p=patch' magic is due to how closures work self.addCleanup(lambda p=patch: p.stop()) utils._EXECUTOR = futurist.SynchronousExecutor(green=True)
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ session = db.get_writer_session() with session.connection() as connection: context.configure( connection=connection, target_metadata=target_metadata ) with context.begin_transaction(): context.run_migrations()
def _create_node(self): session = db.get_writer_session() with session.begin(): db.Node(uuid=self.node_info.uuid, state=istate.States.starting).save(session)