コード例 #1
0
def test_update_invalid_token(user_1, logout_user_1):
    """ Testing user cant change name with an invalid token
    """
    auth.auth_logout(user_1['token'])
    with pytest.raises(AccessError):
        user.user_profile_setname(user_1['token'], 'Bobby', 'Smith')
    clear()
コード例 #2
0
def test_update_name(user_1):
    """ Testing the basic functionality of updating a name
    """
    user.user_profile_setname(user_1['token'], 'Bobby', 'Smith')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            assert account['name_first'] == 'Bobby'
            assert account['name_last'] == 'Smith'
    clear()
コード例 #3
0
def test_update_consecutively(user_1):
    """ Testing wheter the same token allows users to continously change their name
    """
    user.user_profile_setname(user_1['token'], 'Bobby', 'Smith')
    user.user_profile_setname(user_1['token'], 'Snake', 'City')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            assert account['name_first'] == 'Snake'
            assert account['name_last'] == 'City'
            break
    user.user_profile_setname(user_1['token'], 'Goku', 'Vegeta')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            assert account['name_first'] == 'Goku'
            assert account['name_last'] == 'Vegeta'
            break
    user.user_profile_setname(user_1['token'], 'Will', 'Smith')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_1['u_id']:
            assert account['name_first'] == 'Will'
            assert account['name_last'] == 'Smith'
            break
    clear()
コード例 #4
0
def route_user_profile_setname():
    payload = request.get_json()
    token = payload['token']
    name_first = payload['name_first']
    name_last = payload['name_last']
    try:
        return dumps(user.user_profile_setname(token, name_first, name_last))
    except (InputError, AccessError) as e:
        return e
コード例 #5
0
def test_update_multiple_users(user_1, user_2, user_3, user_4):
    """ Testing if users name fields are appropiately changed in largely stored data
    """
    user.user_profile_setname(user_3['token'], 'Popcorn', 'Smoothie')
    user.user_profile_setname(user_2['token'], 'Krillin', 'Bulma')
    user_list = users_all(user_1['token'])
    for account in user_list['users']:
        if account['u_id'] == user_2['u_id']:
            assert account['name_first'] == 'Krillin'
            assert account['name_last'] == 'Bulma'
        if account['u_id'] == user_3['u_id']:
            assert account['name_first'] == 'Popcorn'
            assert account['name_last'] == 'Smoothie'
        if account['u_id'] == user_1['u_id']:
            assert account['name_first'] == 'John'
            assert account['name_last'] == 'Smith'
        if account['u_id'] == user_4['u_id']:
            assert account['name_first'] == 'Janice'
            assert account['name_last'] == 'Smith'
    clear()
コード例 #6
0
def test_change_channel_data(user_1, user_2):
    """ Testing that name is updated in channels section in data structure.
    """
    # creating a new channel
    new_channel = channels.channels_create(user_1['token'], 'Group 1', True)
    channel.channel_invite(user_1['token'], new_channel['channel_id'],
                           user_2['u_id'])
    channel.channel_join(user_2['token'], new_channel['channel_id'])
    channel.channel_addowner(user_1['token'], new_channel['channel_id'],
                             user_2['u_id'])
    details = channel.channel_details(user_1['token'],
                                      new_channel['channel_id'])
    for member in details['all_members']:
        if member['u_id'] == user_1['u_id']:
            assert member['name_first'] == 'John'
            assert member['name_last'] == 'Smith'
        if member['u_id'] == user_2['u_id']:
            assert member['name_first'] == 'Jane'
            assert member['name_last'] == 'Smith'

    for owner in details['owner_members']:
        if owner['u_id'] == user_1['u_id']:
            assert owner['name_first'] == 'John'
            assert owner['name_last'] == 'Smith'
        if owner['u_id'] == user_2['u_id']:
            assert owner['name_first'] == 'Jane'
            assert owner['name_last'] == 'Smith'

    user.user_profile_setname(user_2['token'], 'Bobby', 'Wills')
    details = channel.channel_details(user_1['token'],
                                      new_channel['channel_id'])
    for member in details['all_members']:
        if member['u_id'] == user_2['u_id']:
            assert member['name_first'] == 'Bobby'
            assert member['name_last'] == 'Wills'

    for owner in details['owner_members']:
        if owner['u_id'] == user_2['u_id']:
            assert owner['name_first'] == 'Bobby'
            assert owner['name_last'] == 'Wills'
    clear()
コード例 #7
0
def test_invalid_chars(user_1):
    """ Testing if non english alphabets are rejected, with the exception of '-'
    """
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], 'A92!0F', 'Smith')
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], 'Smith', 'A92!0F')
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], 'A92!0F', 'A92!0F')
    clear()
コード例 #8
0
def test_update_min_name(user_1):
    """ Testing the minimum limits of what a user can change their name to.
    """
    user.user_profile_setname(user_1['token'], 'C', 'S')
    user.user_profile_setname(user_1['token'], 'Chris', 'S')
    user.user_profile_setname(user_1['token'], 'C', 'Smith')
    # empty string does not change the name
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], '', 'Smith')
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], 'Bob', '')
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], '', '')
    clear()
コード例 #9
0
def test_update_max_name(user_1):
    """ Testing the maximum limits of what a user can change their name to
    """
    user.user_profile_setname(user_1['token'], 'C' * 50, 'Smith')
    user.user_profile_setname(user_1['token'], 'Chris', 'S' * 50)
    user.user_profile_setname(user_1['token'], 'C' * 50, 'S' * 50)
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], 'C' * 51, 'Smith')
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], 'Chris', 'S' * 51)
    with pytest.raises(InputError):
        user.user_profile_setname(user_1['token'], 'C' * 51, 'S' * 51)
    clear()