Example #1
0
def test_handle_exists(user_1, user_2):
    """ Testing changing to a user handle that already exists.
    """
    user.user_profile_sethandle(user_1['token'], 'sameHandle')
    with pytest.raises(InputError):
        user.user_profile_sethandle(user_2['token'], 'sameHandle')
    clear()
Example #2
0
def test_update_handle_invalid_token(user_1):
    """ Testing that an invalid token will not allow you to change the handle
    """
    auth.auth_logout(user_1['token'])
    with pytest.raises(AccessError):
        user.user_profile_sethandle(user_1['token'], 'blahblah')
    clear()
Example #3
0
def route_user_profile_sethandle():
    payload = request.get_json()
    try:
        return dumps(
            user.user_profile_sethandle(payload['token'],
                                        payload['handle_str']))
    except (InputError, AccessError) as e:
        return e
Example #4
0
def test_handle_min(user_1):
    """ Testing the minimum characters a handle can achieve
    """
    user.user_profile_sethandle(user_1['token'], 'c' * 3)
    user.user_profile_sethandle(user_1['token'], 'c' * 10)
    with pytest.raises(InputError):
        user.user_profile_sethandle(user_1['token'], 'c' * 2)
    with pytest.raises(InputError):
        user.user_profile_sethandle(user_1['token'], '')
    clear()
Example #5
0
def test_update_handle(user_1):
    """ Testing the basic functionality of updating a handle
    """
    # getting the current handle string
    prev_handle = ''
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            prev_handle = account['handle_str']
    user.user_profile_sethandle(user_1['token'], 'newHandle')
    # getting the updated handle string
    new_handle = ''
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            new_handle = account['handle_str']

    assert new_handle is not prev_handle
    clear()
Example #6
0
def test_handle_prefix(user_1, user_2, user_3):
    """ Testing basic handle name changes.
    """
    user.user_profile_sethandle(user_1['token'], 'newHandle')
    user.user_profile_sethandle(user_2['token'], 'newHandle1')
    user.user_profile_sethandle(user_3['token'], 'newHandle2')
    clear()
Example #7
0
def test_handle_max(user_1):
    """ Testing the maximum characters a handle can achieve
    """
    user.user_profile_sethandle(user_1['token'], 'c' * 20)
    user.user_profile_sethandle(user_1['token'], 'c' * 15)
    with pytest.raises(InputError):
        user.user_profile_sethandle(user_1['token'], 'c' * 21)
    clear()
Example #8
0
def test_handle_consecutive(user_1):
    """ Testing the process of changing handle string consecutively
    """
    user.user_profile_sethandle(user_1['token'], 'newHandle')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            assert account['handle_str'] == 'newHandle'
    user.user_profile_sethandle(user_1['token'], 'newHandle1')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            assert account['handle_str'] == 'newHandle1'
    user.user_profile_sethandle(user_1['token'], 'newHandle2')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            assert account['handle_str'] == 'newHandle2'
    clear()