def test_edit_user_including_email(db_session):
    user = _create_user_data(db_session, confirmed=True)

    first_name = 'New'
    last_name = 'Name'
    email = '*****@*****.**'
    age_group_1 = False
    age_group_2 = True
    age_group_3 = False

    user = us.edit_user(
        current_email=user.email,
        first_name=first_name,
        last_name=last_name,
        email=email,
        age_group_1=age_group_1,
        age_group_2=age_group_2,
        age_group_3=age_group_3
    )

    assert user.first_name == first_name
    assert user.last_name == last_name
    assert user.email == email
    assert user.age_group_1 == age_group_1
    assert user.age_group_2 == age_group_2
    assert user.age_group_3 == age_group_3
    assert not user.confirmed
def test_edit_user_except_email(db_session):
    user = _create_user_data(db_session, confirmed=True)
    db_session.add(user)
    db_session.commit()

    first_name = 'New'
    last_name = 'Name'
    age_group_1 = False
    age_group_2 = True
    age_group_3 = False

    user = us.edit_user(
        current_email=user.email,
        first_name=first_name,
        last_name=last_name,
        email=user.email,
        age_group_1=age_group_1,
        age_group_2=age_group_2,
        age_group_3=age_group_3
    )

    assert user.first_name == first_name
    assert user.last_name == last_name
    assert user.email == user.email
    assert user.age_group_1 == age_group_1
    assert user.age_group_2 == age_group_2
    assert user.age_group_3 == age_group_3
    assert user.confirmed
def test_edit_invalid_user():
    first_name = 'New'
    last_name = 'Name'
    email = '*****@*****.**'
    age_group_1 = False
    age_group_2 = True
    age_group_3 = False

    with pytest.raises(us.InvalidUserError):
        user = us.edit_user(
            current_email='*****@*****.**',
            first_name=first_name,
            last_name=last_name,
            email=email,
            age_group_1=age_group_1,
            age_group_2=age_group_2,
            age_group_3=age_group_3
        )
def test_edit_unconfirmed_user(db_session):
    user = _create_user_data(db_session, confirmed=False)

    first_name = 'New'
    last_name = 'Name'
    email = '*****@*****.**'
    age_group_1 = False
    age_group_2 = True
    age_group_3 = False

    with pytest.raises(us.NotConfirmedUserError):
        user = us.edit_user(
            current_email=user.email,
            first_name=first_name,
            last_name=last_name,
            email=email,
            age_group_1=age_group_1,
            age_group_2=age_group_2,
            age_group_3=age_group_3
        )