예제 #1
0
def test_update_user(db_conn):
    create_test_users(db_conn)
    prev_data = get_user_by_id(db_conn, {'id': user_a_uuid})
    assert prev_data
    data = {'email': 'another'}
    user, errors = update_user(db_conn, prev_data, data)
    assert errors
    assert not user
    data = {'email': '*****@*****.**'}
    user, errors = update_user(db_conn, prev_data, data)
    assert not errors
    assert user
예제 #2
0
def test_update_user(db_conn, users_table):
    """
    Expect to update a user's data.
    """

    user, errors = insert_user({"name": "Dalton", "email": "*****@*****.**", "password": "******"}, db_conn)
    user2, errors2 = update_user(user, {"email": "*****@*****.**"}, db_conn)
    assert len(errors2) == 0
    assert user["name"] == user2["name"]
    assert user["email"] != user2["email"]
예제 #3
0
def test_update_user(db_conn, users_table):
    """
    Expect to update a user's data.
    """

    user, errors = insert_user(
        {
            'name': 'Dalton',
            'email': '*****@*****.**',
            'password': '******',
        }, db_conn)
    user2, errors2 = update_user(user, {'email': '*****@*****.**'}, db_conn)
    assert len(errors2) == 0
    assert user['name'] == user2['name']
    assert user['email'] != user2['email']
예제 #4
0
def update_user_route(request, user_id):
    """
    Update the user. Must be the current user.
    """

    db_conn = request["db_conn"]
    user = get_user({"id": user_id}, db_conn)
    current_user = get_current_user(request)
    if not user:
        return abort(404)
    if not user["id"] == current_user["id"]:
        return abort(401)
    user, errors = update_user(user, request["params"], db_conn)
    if len(errors):
        return 400, {"errors": errors, "ref": "AS7LCAWiOOyeEbNOrbsegVY9"}
    return 200, {"user": deliver_user(user, access="private")}
예제 #5
0
def update_user_route(request, user_id):
  """
  Update the user. Must be the current user.
  """

  db_conn = request['db_conn']
  user = get_user(db_conn, {'id': user_id})
  current_user = get_current_user(request)
  if not user:
    return abort(404, 'Fw7IK0u9TXWxs3Rp15AY1g')
  if not user['id'] == current_user['id']:
    return abort(401, '7QK-6fOcQW-sA99KHtcARA')
  user, errors = update_user(db_conn, user, request['params'])
  if errors:
    return 400, {
      'errors': errors,
      'ref': '61YNw4gWTAKRQxXLYiznBw',
    }
  return 200, {'user': deliver_user(user, access='private')}
예제 #6
0
파일: user.py 프로젝트: m3rryqold/sagefy
def update_user_route(request, user_id):
    """
    Update the user. Must be the current user.
    """

    db_conn = request['db_conn']
    user = get_user({'id': user_id}, db_conn)
    current_user = get_current_user(request)
    if not user:
        return abort(404)
    if not user['id'] == current_user['id']:
        return abort(401)
    user, errors = update_user(user, request['params'], db_conn)
    if len(errors):
        return 400, {
            'errors': errors,
            'ref': 'AS7LCAWiOOyeEbNOrbsegVY9',
        }
    return 200, {'user': deliver_user(user, access='private')}