コード例 #1
0
def test_user_update(app):
    user = User.find_by_id(_SOME_USER_ID)
    assert user.name != _UPDATED_NAME

    user.update({"name": _UPDATED_NAME})
    user.save()

    user = User.find_by_id(_SOME_USER_ID)
    assert user.name == _UPDATED_NAME
コード例 #2
0
def test_user_update_password(app):
    user = User.find_by_id(_SOME_USER_ID)
    current_hash = user.password
    some_pass = "******"

    user.update({"password": some_pass})
    user.save()

    user = User.find_by_id(_SOME_USER_ID)
    assert user.password != current_hash
    assert user.verify_passw(some_pass, user.password)
コード例 #3
0
def test_get_user_messages(app):
    user = User.find_by_id(_SOME_USER_ID)
    all_messages: Dict[str, List] = user.get_messages()

    received_message_ids = {message.id for message in all_messages["received"]}
    sent_message_ids = {message.id for message in all_messages["sent"]}

    assert received_message_ids == _RECEIVED_MESSAGES_IDS_BY_SOME_USER
    assert sent_message_ids == _SENT_MESSAGES_IDS_BY_SOME_USER
コード例 #4
0
def test_some_user_password(app):
    user = User.find_by_id(_SOME_USER_ID)

    assert user.password != _SOME_USER_PASSWORD
    # same string if generate again shows different hash
    assert user.password != user.generate_passw(_SOME_USER_PASSWORD)

    # check that some_password and hash that stored are actually the same
    assert user.verify_passw(_SOME_USER_PASSWORD, user.password)
コード例 #5
0
def create_new_message(recipient: int, subject="Lorem", body: str = "Lorem"):
    if (recipient := User.find_by_id(recipient)) is None:
        return errors.bad_request("Recipient is not found.")
コード例 #6
0
def test_user_delete(app):
    user = User.find_by_id(_SOME_USER_ID)
    assert user.delete()
コード例 #7
0
def test_some_user_exists(app):
    assert User.find_by_id(_SOME_USER_ID) is not None
コード例 #8
0
ファイル: security.py プロジェクト: Daoortor/API_v4
def identity(payload):
    user_id = payload['identity']
    return User.find_by_id(user_id)