def client(): BASE_DIR = Path(__file__).resolve().parent.parent app.config["TESTING"] = True app.config["DATABASE"] = BASE_DIR.joinpath(TEST_DB) app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{BASE_DIR.joinpath(TEST_DB)}" db.create_all() # setup yield app.test_client() # tests run here db.drop_all() # teardown
def setUp(self): db.create_all() breed = Breed(name='test') dog = Dog(name='test') user = User(username='******', email='*****@*****.**') user.set_password('test') db.session.add(breed) db.session.add(dog) db.session.add(user) db.session.commit()
def recreatedb(): db.drop_all() db.create_all() db.session.commit()
# create_db.py from project.app import db # create the database and the db table db.create_all() # commit the changes db.session.commit()
def initdb(): db.create_all()
def create_db(): db.drop_all() db.create_all() db.session.commit() print('Database created!')
def setup(self): db.create_all() db.session.commit()