def seed_database(): db.drop_all() db.create_all() hashed_password = generate_password_hash("password") admin = User(email="*****@*****.**", hashed_password=hashed_password, is_admin=True) db.session.add(admin) db.session.commit()
def setup_test(self): db.session.commit() db.drop_all() db.create_all()
try: data = s.loads(token) # except SignatureExpired: # return None # valid token, but expired # except BadSignature: # return None # invalid token except Exception: return None user = User.query.get(data['id']) return user def __repr__(self): return 'User name=%s' % self.username def import_user(): for i in range(1000, 3000, 3): user = User('jobs' + str(i) + '@gmail.com') user.hash_password('1') user.email = 'jobs' + str(i) + '@gmail.com' user.phone = '1786678' + str(i) db.session.add(user) db.session.commit() if __name__ == '__main__': db.drop_all() db.create_all() db.session.commit() import_user()
def drop_db(): """Drops the db tables.""" db.drop_all()
def tearDown(self): db.session.remove() db.drop_all()
def reset(self, app): with app.app_context(): db.drop_all() db.create_all()