def test_get_user(data_fixture):
    user_1 = data_fixture.create_user(email='user1@localhost')

    handler = UserHandler()

    with pytest.raises(ValueError):
        handler.get_user()

    with pytest.raises(UserNotFound):
        handler.get_user(user_id=-1)

    with pytest.raises(UserNotFound):
        handler.get_user(email='user3@localhost')

    assert handler.get_user(user_id=user_1.id).id == user_1.id
    assert handler.get_user(email=user_1.email).id == user_1.id
Example #2
0
    def post(self, request, data):
        """
        If the email is found, an email containing the password reset link is send to
        the user.
        """

        handler = UserHandler()

        try:
            user = handler.get_user(email=data["email"])
            handler.send_reset_password_email(user, data["base_url"])
        except UserNotFound:
            pass

        return Response("", status=204)