def client(app): with app.test_client() as client: _db.app = app _db.create_all() yield client _db.session.rollback() _db.drop_all()
def drop(): """Drops database tables""" if prompt_bool("Are you sure you want to lose all your data"): from application.models.logic import Logic db.metadata.drop_all(db.engine, tables=[Logic.__table__]) db.drop_all() redis.flushall()
def refresh(): """Drops database, recreates it and inserts fake data in tables and redis""" from application.models.logic import Logic db.metadata.drop_all(db.engine, tables=[Logic.__table__]) db.drop_all() redis.flushall() create() fake()
def my_teardown(obj): """Call this function from tearDown as: def tearDown(self): my_teardown(self) """ db.session.remove() db.drop_all() obj.app_context.pop()
def init_db(): db.create_all() db.session.add(User( username="******", password=guard.hash_password("admin"), roles="admin" )) db.session.add(PortfolioImage( title="Test", category="portrait", client="Der Boi" )) db.session.add(PortfolioVideo( title="Test", category="aftermovie", client="Der Boi", video="ilusrhgiur" )) db.session.commit() yield db db.drop_all()
def drop_db(): """ Drop Database """ db.drop_all()
def dropall(): """Drops all database tables""" if prompt_bool("Are you sure ? You will lose all your data !"): db.drop_all()
def teardown(): _db.drop_all()
def drop_all(): if prompt_bool("Are you sure? You will lose all your data!"): db.drop_all()
def teardown(): _db.drop_all() os.unlink(app.config["TEST_DB"])
def drop(): """Drops database tables""" if prompt_bool("Are you sure you want to lose all your data"): db.drop_all() redis.flushdb()
def tearDownClass(cls): with cls.app.app_context(): db.drop_all() db.session.remove() cls.app.extensions['redis'].flushdb()