Пример #1
0
def test_user_name_unique(session):
    user1, user2 = User(name='first', password='******'), User(name='first',
                                                            password='******')
    session.add_all((user1, user2))

    with pytest.raises(IntegrityError):
        session.commit()
Пример #2
0
def test_user_set_password(session):
    user = User()
    user.set_password('password')

    assert user.password_hash is not None
    assert user.password_hash != 'password'

    user2 = User(password='******')
    assert user2.password_hash is not None
    assert user2.password_hash != 'password'
Пример #3
0
def test_user_name_non_null(session):
    user = User(password='******')
    session.add(user)

    with pytest.raises(IntegrityError):
        session.commit()
Пример #4
0
def test_user_password_non_null(session):
    user = User(name='garrett')
    session.add(user)

    with pytest.raises(IntegrityError):
        session.commit()