def setUp(self): db.session.commit() db.drop_all() db.create_all() self.user = User(email='*****@*****.**', password=crypt.generate_password_hash('9797ifdhvsd'), balance=10) db.session.add(self.user) db.session.commit()
def setUp(self): # this gets called before every test so there's always the same data for the program to test db.session.commit() db.drop_all() db.create_all() # this ensures that the databse is completely empty by destroying and rebuilding it hashed_pw = bcrypt.generate_password_hash("admin") admin = Users(first_name="admin", last_name="admin", email="*****@*****.**", password=hashed_pw) # creates the first (admin) test user hashed_pw_2 = bcrypt.generate_password_hash("password") avguser = Users(first_name="test", last_name="user", email="*****@*****.**", password=hashed_pw_2) # creates the second (non-admin) test user db.session.add(admin) db.session.add(avguser) db.session.commit()
#!flask/bin/python from migrate.versioning import api from config import SQLALCHEMY_DATABASE_URI from config import SQLALCHEMY_MIGRATE_REPO from Application import db import os.path db.create_all() if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository') api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) else: api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
def init_app(): init_login() admin = Admin(app) admin.add_view(AdminViews(name='Admin View')) if __name__ == '__main__': init_app() db.create_all() #Now we create a SUPERUSER in the User table if not created earlier. superuser = User.query.filter(User.email == SUPERUSER_USERNAME).scalar() if not superuser: try: entry = User(SUPERUSER_USERNAME,SUPERUSER_PASSWORD,True) db.session.add(entry) db.session.commit() except: db.session.rollback() app.run()
def setUp(self): self.existing_researcher = Researchers(phone_id='123', name='test', surname='test') app.config.from_pyfile('../Tests/testing_conf.py') self.app = app.test_client() db.create_all()
def setUp(self): app.config.from_pyfile('../Tests/testing_conf.py') self.app = app.test_client() db.create_all()
def setUp(self): app.config.from_pyfile('../Tests/test_configuration.py') self.app = application.app.test_client() self.importer = ChessGameParser() db.create_all()
def setUp(self): application.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' db.create_all()