Пример #1
0
def test_password_hashing():
    with app.app_context():
        db.create_all()

        new_user = User(username='******', email='*****@*****.**')

        password = '******'

        new_user.set_password(password)

        new_user.save()

        assert new_user.check_password('password') == True
Пример #2
0
def test_user_creation():

    with app.app_context():
        db.create_all()

        username = '******'
        email = '*****@*****.**'
        password = '******'

        new_user = User(username=username, email=email)

        new_user.set_password(password)

        new_user.save()

        user = User.query.filter_by(username=username).first()

        assert user.username == username
Пример #3
0
from main.models.users import User
from main.utils.database import db
from main import app
from main.config import TestConfig

app.config.from_object(TestConfig)
db.init_app(app)

with app.app_context():
    db.create_all()

    new_user = User(username='******', email='*****@*****.**')

    new_user.set_password('testpassword')

    new_user.save()


def test_password_reset():

    old_password = '******'

    new_password = '******'

    new_user.reset_password(old_password, new_password)

    assert new_user.check_password('newpassword') == True