Exemple #1
0
def create_user_query(db: Session, user: schemas.UserCreate):
    hashed_password = get_password_hash(user.password)
    db_user = models.User(email=user.email,
                          username=user.username,
                          hashed_password=hashed_password)
    db.add(db_user)
    db.commit()
    db.refresh(db_user)
    return db_user
Exemple #2
0
    def test_user(self):
        test_user = models.User(email='*****@*****.**',
                                password='******')

        self.db.session.add(test_user)
        self.db.session.commit()

        result = models.User.query.get(test_user.id)
        self.assertDictEqual(result.dict, {
            'id': 1,
            'email': '*****@*****.**',
            'password': '******'
        })
Exemple #3
0
import app.admin.models as admin

print('create database schema')
db.create_all()

print('create groups')
admin_group = users.Group('Administrators', '')
admin_group.id = 1
user_group = users.Group('Public Users', '')
user_group.id = 2
db.session.add(admin_group)
db.session.add(user_group)

print('create first admin user')
user = users.User(username='******',
                  email=config.EMAIL['address'],
                  password='******')
user.banned = 0
user.groups.append(admin_group)
user.groups.append(user_group)
db.session.add(user)

print('create version tag')
version_tag = admin.SystemParameter()
version_tag.name = 'version'
version_tag.value = '1.00'
db.session.add(version_tag)

print('commit to database')
db.session.commit()
print('finish')
Exemple #4
0
    def test_not_is_admin(self):
        test_user = models.User(email='*****@*****.**',
                                password='******')

        self.assertFalse(models.User.is_admin(test_user))