def setup(self, dbname): db = self.databases[dbname]['db'] path = self.databases[dbname]['file'] migrations = self.databases[dbname]['migrations'] db.recreate(path) if migrations: Database.migrate(db, migrations, self.conf)
def add_database(self, database): name = database['name'] migrations = database.get('migrations') db_file = os.path.join( self.dbdir, random_name('test_{}'.format(name))) conn = Database.connect(database=db_file) self.databases[name] = { 'file': db_file, 'db': Database(conn), 'migrations': migrations, }
def teardown(self, dbname): path = self.databases[dbname]['file'] db = self.databases[dbname]['db'] db.close() Database.drop(path)