Beispiel #1
0
    def create_app(self):
        app.testing = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
        app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
        app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
        app.config['WTF_CSRF_ENABLED'] = False
        with app.app_context():
            db.drop_all()
            db.create_all()
            self.db = db
            user = User(
                name='admin',
                email='*****@*****.**',
                password='******'
            )

            shelter = Shelter(
                name='Swell Friendly Place'
            )

            puppy = Puppy(
                name='Ralph',
                gender='female',
                picture='dog-187817_640.jpg',
                shelter=shelter
            )

            db.session.add(user)
            db.session.add(shelter)
            db.session.add(puppy)
            db.session.commit()
        return app
Beispiel #2
0
from leash import db, app
from leash.models import User

db.drop_all()
db.create_all()

admin_email = app.config['ADMIN_EMAIL']
admin_password = app.config['ADMIN_PASSWORD']
user = User(email=admin_email, password=admin_password, role='admin')
db.session.add(user)
db.session.commit()