Esempio n. 1
0
def test_user_profile_does_not_exist():
    '''
    user does not exist
    '''
    j_id, j_token = login("*****@*****.**", "cre4t1v3p4s5")
    with pytest.raises(HTTPError):
        user_profile(j_token, j_id + 1)
    logout(j_token)
Esempio n. 2
0
def test_user_profile_invalid_token(reset):
    '''
    invalid request with invalid token
    '''
    j_id, j_token = register("*****@*****.**", "cre4t1v3p4s5", "Joshua",
                             "Wang")
    with pytest.raises(HTTPError):
        user_profile(j_token + 'x', j_id)
Esempio n. 3
0
def test_user_profile_sethandle(reset):
    '''
    Valid request to set handle
    '''
    j_id, j_token = register("*****@*****.**", "cre4t1v3p4s5", "Joshua",
                             "Wang")

    user_profile_sethandle(j_token, "fredmerc1")
    profile = user_profile(j_token, j_id)

    assert profile["handle_str"] == "fredmerc1"
Esempio n. 4
0
def test_user_profile_setemail(reset):
    '''
    can set email
    '''
    j_id, j_token = register("*****@*****.**", "cre4t1v3p4s5", "Joshua",
                             "Wang")

    user_profile_setemail(j_token, "*****@*****.**")
    profile = user_profile(j_token, j_id)

    assert profile["email"] == "*****@*****.**"
Esempio n. 5
0
def test_user_profile_setname(reset):
    '''
    valid request to set name
    '''
    j_id, j_token = register("*****@*****.**", "cre4t1v3p4s5", "Joshua",
                             "Wang")

    user_profile_setname(j_token, "Freddie", "Mercury")
    profile = user_profile(j_token, j_id)

    assert profile["name_first"] == "Freddie"
    assert profile["name_last"] == "Mercury"
Esempio n. 6
0
def test_user_profile_own(reset):
    '''
    getting your own information
    '''
    j_id, j_token = register("*****@*****.**", "cre4t1v3p4s5", "Joshua",
                             "Wang")
    payload = user_profile(j_token, j_id)
    assert payload == {
        "u_id": j_id,
        "email": "*****@*****.**",
        "name_first": "Joshua",
        "name_last": "Wang",
        "handle_str": "joshuawang",
        "profile_img_url": ""
    }
    logout(j_token)
Esempio n. 7
0
def test_user_profile_logged_out():
    '''
    info of a logged out user
    '''
    j_token = login("*****@*****.**", "cre4t1v3p4s5")[1]
    k_id, k_token = login("*****@*****.**", "IAMAMUSICIAN")

    logout(k_token)

    payload = user_profile(j_token, k_id)
    assert payload == {
        "u_id": k_id,
        "email": "*****@*****.**",
        "name_first": "Ken",
        "name_last": "Li",
        "handle_str": "kenli",
        "profile_img_url": ""
    }

    logout(j_token)
Esempio n. 8
0
def test_user_profile():
    '''
    valid request
    '''
    j_token = login("*****@*****.**", "cre4t1v3p4s5")[1]
    k_id, k_token = register("*****@*****.**", "IAMAMUSICIAN", "Ken",
                             "Li")

    payload = user_profile(j_token, k_id)
    assert payload == {
        "u_id": k_id,
        "email": "*****@*****.**",
        "name_first": "Ken",
        "name_last": "Li",
        "handle_str": "kenli",
        "profile_img_url": ""
    }

    logout(j_token)
    logout(k_token)