def db(): from service import db with app.app_context(): db.create_all() yield db db.drop_all() db.session.commit()
def client(): ## Setup for each test ## app.config['TESTING'] = True app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@testdb:5432/mytestdb' client = app.test_client() with app.app_context(): db.create_all() yield client ## Teardown for each test ## with app.app_context(): db.session.close() db.drop_all()
def drop(): "Drops all database tables" if prompt_bool("Are you sure you want to lose all your data"): db.drop_all()
def recreate_db(): db.drop_all() db.create_all() db.session.commit()
def tearDown(self): db.session.remove() db.drop_all()
def drop(): "Drops All Database Tables" if prompt_bool('Are you sure you want to drop all tables', default=False): db.drop_all()
def tearDown(self): ''' Tear down the database. ''' db.session.remove() db.drop_all()
def drop_db(): db.drop_all() db.session.commit()