def db():
    """Get a db session"""
    # make sure some initial db contents are filled out
    # specifically, the 'default' jupyterhub oauth client
    app = MockHub(db_url='sqlite:///:memory:')
    app.init_db()
    _db = app.db
    for role in get_default_roles():
        create_role(_db, role)
    user = orm.User(name="user")
    _db.add(user)
    _db.commit()
    assign_default_roles(_db, user)
    _db.commit()
    return _db
Get a db session
jupyterhub/tests/conftest.py