Esempio n. 1
0
def mongodb(request):
    """Set up a mongo connection reset and ready to roll.
    """
    from pp.user.model import db as mongo

    log = get_log('mongodb')

    dbname = "testingdb-{}".format(uuid.uuid4().hex)

    mongo.init(dict(dbname=dbname))
    db = mongo.db()
    db.hard_reset()
    log.info('database ready for testing "{}"'.format(dbname))

    def db_teardown(x=None):
        db.hard_reset()
        log.warn('teardown database for testing "{}"'.format(dbname))

    request.addfinalizer(db_teardown)

    return db