Beispiel #1
0
    def setUp(self):
        class TestConfig(object):
            SQLALCHEMY_DATABASE_URI = 'sqlite://'
            DEBUG = True
            TESTING = True

        app.config.from_object(TestConfig())

        self.app = app

        with self.app.test_request_context():
            db.create_all()
            raw_users = [
                {
                    'username': '******',
                    'email': '*****@*****.**',
                    'password': '******'
                }, {
                    'username': '******',
                    'email': '*****@*****.**',
                    'password': '******'
                }, {
                    'username': '******',
                    'email': '*****@*****.**',
                    'password': '******'
                }
            ]
            raw_groups = [
                {
                    'name': 'group1'
                }, {
                    'name': 'group2'
                }, {
                    'name': 'group3'
                }
            ]
            for user in raw_users:
                password = user.pop('password')
                user = User(**user)
                user.set_password(password)
                user.save()

            for group in raw_groups:
                Group(**group).save()
Beispiel #2
0
    def setUp(self):
        class TestConfig(object):
            SQLALCHEMY_DATABASE_URI = 'sqlite://'
            DEBUG = True
            TESTING = True

        app.config.from_object(TestConfig())

        self.app = app

        with self.app.test_request_context():
            db.create_all()
            raw_users = [{
                'username': '******',
                'email': '*****@*****.**',
                'password': '******'
            }, {
                'username': '******',
                'email': '*****@*****.**',
                'password': '******'
            }, {
                'username': '******',
                'email': '*****@*****.**',
                'password': '******'
            }]
            raw_groups = [{
                'name': 'group1'
            }, {
                'name': 'group2'
            }, {
                'name': 'group3'
            }]
            for user in raw_users:
                password = user.pop('password')
                user = User(**user)
                user.set_password(password)
                user.save()

            for group in raw_groups:
                Group(**group).save()
Beispiel #3
0
def create_user(username, email, password):
    newuser = User(username=username, email=email)  # create user object
    newuser.set_password(password)  # set password
    db.session.add(newuser)
    db.session.commit()
from main import app, db, User

db.create_all(app=app)

bob = User(username="******", email = "*****@*****.**")
bob.set_password("bobpass")
john = User(username="******", email="*****@*****.**")
john.set_password('johnpass')
db.session.add(bob)
db.session.add(john)
db.session.commit()

print('database initialized!')

Beispiel #5
0
from main import app, db, User

db.create_all(app=app)

user = User(username='******')
user.set_password('bobpass')
db.session.add(user)
db.session.commit()

print('database initialized!')