Esempio n. 1
0
def recreate(dbList):
    """Drop and re-init specific databases. If dbList is 'all', do everything."""
    if dbList == 'all':
        list = []
        # get list of databases to recreate based on current config settings
        list.append(dataactcore.config.CONFIG_DB['user_db_name'])
        list.append(dataactcore.config.CONFIG_DB['job_db_name'])
        list.append(dataactcore.config.CONFIG_DB['error_db_name'])
        # TODO: add validator after the repo merge
    else:
        # TODO: if this script gets used a lot, put in some error-checking
        list = dbList

    for db in list:
        print('Recreating {}'.format(db))
        dropDatabase(db)
        if 'error' in db:
            dataactcore.config.CONFIG_DB['error_db_name'] = db
            setupErrorDB()
        if 'user' in db:
            dataactcore.config.CONFIG_DB['user_db_name'] = db
            setupUserDB()
        if 'job' in db:
            dataactcore.config.CONFIG_DB['job_db_name'] = db
            setupJobTrackerDB()
def recreate(dbList):
    """Drop and re-init specific databases. If dbList is 'all', do everything."""
    if dbList == 'all':
        list = []
        # get list of databases to recreate based on current config settings
        list.append(dataactcore.config.CONFIG_DB['user_db_name'])
        list.append(dataactcore.config.CONFIG_DB['job_db_name'])
        list.append(dataactcore.config.CONFIG_DB['error_db_name'])
        # TODO: add validator after the repo merge
    else:
        # TODO: if this script gets used a lot, put in some error-checking
        list = dbList

    for db in list:
        print ('Recreating {}'.format(db))
        dropDatabase(db)
        if 'error' in db:
            dataactcore.config.CONFIG_DB['error_db_name'] = db
            setupErrorDB()
        if 'user' in db:
            dataactcore.config.CONFIG_DB['user_db_name'] = db
            setupUserDB()
        if 'job' in db:
            dataactcore.config.CONFIG_DB['job_db_name'] = db
            setupJobTrackerDB()
 def tearDownClass(cls):
     """Tear down class-level resources."""
     cls.interfaces.close()
     dropDatabase(cls.interfaces.jobDb.dbName)
     dropDatabase(cls.interfaces.errorDb.dbName)
     dropDatabase(cls.interfaces.stagingDb.dbName)
     dropDatabase(cls.interfaces.validationDb.dbName)
Esempio n. 4
0
 def tearDownClass(cls):
     """Tear down class-level resources."""
     cls.interfaces.close()
     dropDatabase(cls.interfaces.jobDb.dbName)
     dropDatabase(cls.interfaces.errorDb.dbName)
     dropDatabase(cls.interfaces.stagingDb.dbName)
     dropDatabase(cls.interfaces.validationDb.dbName)
Esempio n. 5
0
def full_database_setup():
    """Sets up a clean database based on the model metadata. It also
    calculates the FK relationships between tables so we can delete them in
    order. It yields a tuple the _DB and ordered list of tables."""
    rand_id = str(randint(1, 9999))

    config = dataactcore.config.CONFIG_DB
    config['db_name'] = 'unittest{}_data_broker'.format(rand_id)
    dataactcore.config.CONFIG_DB = config

    createDatabase(config['db_name'])
    db = dbConnection()
    runMigrations()

    creation_order = baseModel.Base.metadata.sorted_tables
    yield (db, list(reversed(creation_order)))  # drop order

    db.close()
    dropDatabase(config['db_name'])
 def tearDownClass(cls):
     """Tear down class-level resources."""
     cls.interfaces.close()
     dropDatabase(cls.interfaces.userDb.dbName)
     dropDatabase(cls.interfaces.jobDb.dbName)
     dropDatabase(cls.interfaces.errorDb.dbName)
 def tearDownClass(cls):
     """Tear down class-level resources."""
     dropDatabase(CONFIG_DB['db_name'])
Esempio n. 8
0
 def tearDownClass(cls):
     """Tear down class-level resources."""
     cls.interfaces.close()
     dropDatabase(cls.interfaces.userDb.dbName)
     dropDatabase(cls.interfaces.jobDb.dbName)
     dropDatabase(cls.interfaces.errorDb.dbName)