def app(): # setup _app = create_app(TestConfig) # create test tables with _app.app_context(): db.drop_all() db.create_all() yield _app # teardown with _app.app_context(): db.drop_all()
def init_database(): # Create the database and the database table db.create_all() # Insert user data user1 = UserModel('*****@*****.**', 'password1') user2 = UserModel('*****@*****.**', 'password2') user2 = UserModel('*****@*****.**', 'password') db.session.add(user1) db.session.add(user2) # Commit the changes for the users db.session.commit() yield db # This is where the testing happens! db.drop_all()
def init_database(): # Create the database and the database table db.create_all() # Insert user data user1 = User(email='*****@*****.**', plaintext_password='******') user2 = User(email='*****@*****.**', plaintext_password='******') db.session.add(user1) db.session.add(user2) # Commit the changes for the users db.session.commit() yield db # this is where the testing happens! db.drop_all()
def tearDown(self): db.session.remove() db.drop_all()
def recreate_db(): db.drop_all() db.create_all() db.session.commit()
def reset_db(): """Drop the database and recreate it.""" db.drop_all() db.create_all()