Example #1
0
def test_user_profile_invaliduid():
    # set up
    restart()
    authRegisterDict = auth_register("*****@*****.**", "hi123456",
                                     "haodong", "lu")
    token = authRegisterDict['token']

    # testing
    with pytest.raises(ValueError, match=r".*"):
        user_profile(token, -1)
Example #2
0
def user1():
    token = request.args.get('token')
    u_id = request.args.get('u_id')
    profile = user_profile(token, u_id)
    # profile['u_id'] = 3
    # profile['profile_img_url'] = '7'
    return dumps(profile)
Example #3
0
def test1_user_profile_setname():
    restart()
    authRegisterDict = auth_register("*****@*****.**", "hi123456",
                                     "haodong", "lu")
    token = authRegisterDict['token']
    UID = authRegisterDict['u_id']
    user_profile_setname(token, 'daniel', 'quin')
    user = user_profile(token, UID)
    assert 'daniel' == user['name_first']
    assert 'quin' == user['name_last']
Example #4
0
def test_user_profile_functional():
    # set up
    restart()
    authRegisterDict = auth_register("*****@*****.**", "hi123456",
                                     "haodong", "lu")
    token = authRegisterDict['token']
    UID = authRegisterDict['u_id']

    authRegisterDict2 = auth_register("*****@*****.**", "hi1234566789", "jeff",
                                      "lu")
    token2 = authRegisterDict2['token']
    UID2 = authRegisterDict2['u_id']

    authRegisterDict3 = auth_register("*****@*****.**", "hi1234566789",
                                      "normal", "user")
    token3 = authRegisterDict3['token']
    UID3 = authRegisterDict3['u_id']

    # testing
    userDict = user_profile(token, UID)
    mail = userDict['email']
    fname = userDict['name_first']
    lname = userDict['name_last']
    hd = userDict['handle_str']
    assert mail == "*****@*****.**"
    assert fname == "haodong"
    assert lname == "lu"
    assert hd == "haodonglu"

    user2 = user_profile(token2, UID2)

    user3 = user_profile(token3, UID3)
    assert user2['email'] == "*****@*****.**"
    assert user2['name_first'] == "jeff"
    assert user2['name_last'] == "lu"
    assert user2['handle_str'] == "jefflu"
    assert user3['email'] == "*****@*****.**"
    assert user3['name_first'] == "normal"
    assert user3['name_last'] == "user"
    assert user3['handle_str'] == "normaluser"
    with pytest.raises(ValueError, match=r".*"):
        user_profile(token, 12345)
def run_user_profile():
    """
    Run the message_react function to react a message and
    add it to the server database
    """
    request_data = request.args
    return_value = user.user_profile(request_data["token"],
                                     int(request_data["u_id"]),
                                     live_str=f"http://localhost:{PORT}/")

    return dumps(return_value)
Example #6
0
def test1_user_profile_sethandle_normalCases():
    restart()
    authRegisterDict = auth_register("*****@*****.**", "hi123456",
                                     "haodong", "lu")
    token = authRegisterDict['token']
    UID = authRegisterDict['u_id']

    authRegisterDict2 = auth_register("*****@*****.**", "hi1234566789",
                                      "jeffsb", "lu")
    token2 = authRegisterDict2['token']
    UID2 = authRegisterDict2['u_id']

    user_profile_sethandle(token, "jeffisnumb")
    user1 = user_profile(token, UID)

    assert "jeffisnumb" == user1['handle_str']

    user_profile_sethandle(token2, "jeffisdumb")
    user2 = user_profile(token2, UID2)

    assert "jeffisdumb" == user2['handle_str']