def init_db(db_engine): from h import db authority = TEST_SETTINGS['h.authority'] db.init(db_engine, should_drop=True, should_create=True, authority=authority)
def init_db(db_engine): authority = TEST_SETTINGS["h.authority"] db.init(db_engine, should_drop=True, should_create=True, authority=authority)
def app(pyramid_app, db_engine): from h import db _clean_database(db_engine) db.init(db_engine, authority=text_type(TEST_SETTINGS['h.authority'])) return TestApp(pyramid_app)
def app(pyramid_app, db_engine): from h import db _clean_database(db_engine) db.init(db_engine, authority=TEST_SETTINGS["h.authority"]) return TestApp(pyramid_app)
def db_engine(): """Set up the database connection and create tables.""" engine = sqlalchemy.create_engine(TEST_DATABASE_URL) db.init(engine, should_create=True, should_drop=True, authority=TEST_AUTHORITY) return engine
def init_db(db_engine): from h import db authority = text_type(TEST_SETTINGS["h.authority"]) db.init(db_engine, should_drop=True, should_create=True, authority=authority)
def app(pyramid_app, db_engine): from h import db _clean_database(db_engine) _clean_elasticsearch(TEST_SETTINGS) db.init(db_engine, authority=TEST_SETTINGS['h.authority']) return TestApp(pyramid_app)
def db_engine(): db_engine = db.make_engine(TEST_SETTINGS) db.init(db_engine, authority=TEST_SETTINGS["h.authority"], should_create=True) yield db_engine db_engine.dispose()
def with_clean_db(db_engine): tables = reversed(db.Base.metadata.sorted_tables) with contextlib.closing(db_engine.connect()) as conn: tx = conn.begin() tnames = ", ".join('"' + t.name + '"' for t in tables) conn.execute(f"TRUNCATE {tnames};") tx.commit() # We need to re-init the DB as it creates the default test group and # possibly more in future? db.init(db_engine, authority=TEST_SETTINGS["h.authority"])
def _init_db(settings): engine = db.make_engine(settings) # If the alembic_version table is present, then the database is managed by # alembic, and we shouldn't call `db.init`. try: engine.execute('select 1 from alembic_version') except sqlalchemy.exc.ProgrammingError: log.info("initializing database") db.init(engine, should_create=True, authority=settings['h.authority']) else: log.info("detected alembic_version table, skipping db initialization")
def _init_db(settings): engine = db.make_engine(settings) # If the alembic_version table is present, then the database is managed by # alembic, and we shouldn't call `db.init`. try: engine.execute("select 1 from alembic_version") except sqlalchemy.exc.ProgrammingError: log.info("initializing database") db.init(engine, should_create=True, authority=settings["h.authority"]) # Stamp the database with the current schema version so that future # migrations start from the correct point. alembic_cfg = alembic.config.Config("conf/alembic.ini") alembic.command.stamp(alembic_cfg, "head") else: log.info("detected alembic_version table, skipping db initialization")
def _init_db(settings): engine = db.make_engine(settings) # If the alembic_version table is present, then the database is managed by # alembic, and we shouldn't call `db.init`. try: engine.execute("select 1 from alembic_version") except sqlalchemy.exc.ProgrammingError: log.info("initializing database") db.init( engine, should_create=True, authority=text_type(settings["h.authority"]) ) # Stamp the database with the current schema version so that future # migrations start from the correct point. alembic_cfg = alembic.config.Config("conf/alembic.ini") alembic.command.stamp(alembic_cfg, "head") else: log.info("detected alembic_version table, skipping db initialization")
def db_engine(): """Set up the database connection and create tables.""" engine = sqlalchemy.create_engine(TEST_DATABASE_URL) db.init(engine, should_create=True, should_drop=True) return engine
def init_db(db_engine): from h import db from h import models # noqa db.init(db_engine, should_drop=True, should_create=True)