def setUp(self): db_session.query(User).delete() email = '*****@*****.**' password = '******' u = User(email, password, u'firstname', u'lastname') u.is_admin = True db_session.add(u) db_session.commit()
def _fixture_setup(self): """ if has fixture, use pickle install it """ db_session.query(User).delete() db_session.commit() user = User('*****@*****.**', '123456', 'ff', 'tt') user.is_admin = True db_session.add(user) db_session.commit()
def login(email, password): """ TODO: unittest return User instance or None """ pw = hashlib.md5(password).digest() user = db_session.query(User).filter(User.email == email).filter(User.password == pw).first() return user
def login(email, password): """ TODO: unittest return User instance or None """ pw = hashlib.md5(password).digest() user = db_session.query(User).filter(User.email == email).filter( User.password == pw).first() return user
def dump_database(f=sys.stdout): # insert the project path project_dir = path.dirname(path.dirname(__file__)) sys.path.insert(0, project_dir) import models # Warn: need the model define __all__ attri # and the Base and db_session need in the __all__ results = [] for model in models.__all__: if issubclass(model, models.Base): datas = db_session.query( getattr(models, model)).all() result.extends(datas) # dumps the data to the file pickle.dump(result, f) print 'dumps database ok'
def tearDown(self): db_session.query(User).delete() db_session.commit() self.br.quit()
def tearDown(self): db_session.query(User).delete() db_session.commit()