Esempio n. 1
0
 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()
Esempio n. 2
0
 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()
Esempio n. 3
0
 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()
Esempio n. 4
0
 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()
Esempio n. 5
0
 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
Esempio n. 6
0
 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
Esempio n. 7
0
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'
Esempio n. 8
0
 def tearDown(self):
     db_session.query(User).delete()
     db_session.commit()
     self.br.quit()
Esempio n. 9
0
 def tearDown(self):
     db_session.query(User).delete()
     db_session.commit()