Exemple #1
0
def setup():
    import mox  # Fail fast if you don't have mox. Workaround for bug 810424

    from manila.db import migration
    from manila.tests import conf_fixture

    conf_fixture.set_defaults(CONF)

    if CONF.sql_connection == "sqlite://":
        if migration.db_version() > 1:
            return
    else:
        testdb = os.path.join(CONF.state_path, CONF.sqlite_db)
        if os.path.exists(testdb):
            return
    migration.db_sync()

    if CONF.sql_connection == "sqlite://":
        global _DB
        engine = get_engine()
        conn = engine.connect()
        _DB = "".join(line for line in conn.connection.iterdump())
    else:
        cleandb = os.path.join(CONF.state_path, CONF.sqlite_clean_db)
        shutil.copyfile(testdb, cleandb)
Exemple #2
0
def setup():
    conf_fixture.set_defaults(CONF)
    if CONF.sql_connection == "sqlite://":
        if migration.db_version() > 1:
            return
    else:
        testdb = os.path.join(CONF.state_path, CONF.sqlite_db)
        if os.path.exists(testdb):
            return
    migration.db_sync()

    if CONF.sql_connection == "sqlite://":
        global _DB
        engine = get_engine()
        conn = engine.connect()
        _DB = "".join(line for line in conn.connection.iterdump())
    else:
        cleandb = os.path.join(CONF.state_path, CONF.sqlite_clean_db)
        shutil.copyfile(testdb, cleandb)