示例#1
0
def test_channel_details_bad():
    data = getdata()
    host = get_host()
    user = data.users_group[0]
    user1 = data.users_group[2]
    # it takes in data, token, channel_name and is_public
    channel = ch_create(data, user.token, '12345', True)

    res1 = ch_details(data, user.token, '123456', host)
    assert res1 == {'ValueError': 'Invalid channel id'}

    res2 = ch_details(data, user1.token, channel['channel_id'], host)
    assert res2 == {'AccessError': 'User is not a member of Channel'}
示例#2
0
def test_channel_removeowner_ok():
    data = getdata()
    host = get_host()
    user_admin = data.users_group[0]
    user1 = data.users_group[1]
    channel = ch_create(data, user_admin.token, '12345', True)

    ch_join_leave(data, user1.token, channel['channel_id'], 'join')

    ch_add_remove_owner(data, user_admin.token, channel['channel_id'],
                        user1.u_id, 'add')
    ch_add_remove_owner(data, user_admin.token, channel['channel_id'],
                        user1.u_id, 'remove')

    channel_profile = ch_details(data, user_admin.token, channel['channel_id'],
                                 host)
    owner_list = channel_profile["owner_members"]
    # if user1["u_id"] is in the owner list
    # Means channel_removeowner is not working
    exist = 0
    if user1.u_id not in owner_list:
        exist = 1
    assert exist == 1

    assert owner_list[0]['u_id'] == user_admin.u_id
示例#3
0
def channel_details():
    global data
    host = request.host_url

    token, channel_id = do_get(request.args, ['token', 'channel_id'])
    result = ch_details(data, token, int(channel_id), host)
    catch_error_and_return(result)
    save()

    return dumps(result)
示例#4
0
def channel_details():
    global data

    token = request.args.get('token')
    channel_id = int(request.args.get('channel_id'))
    channel_detail = ch_details(data, token, channel_id)
    if 'ValueError' in channel_detail:
        raise ValueError(description=channel_detail['ValueError'])
    elif 'AccessError' in channel_detail:
        raise AccessError(description=channel_detail['AccessError'])
    save()

    return dumps(channel_detail)
示例#5
0
def test_channel_join_ok():
    data = getdata()
    host = get_host()
    user = data.users_group[0]
    channel = ch_create(data, user.token, '12345', True)
    user2 = data.users_group[1]
    ch_join_leave(data, user2.token, channel['channel_id'], 'join')
    channel_profile = ch_details(data, user2.token, channel['channel_id'],
                                 host)

    # Check the new user has join the channel
    member_list = channel_profile["all_members"]
    assert member_list[0]['u_id'] == user.u_id
    assert member_list[1]['u_id'] == user2.u_id
示例#6
0
def test_channel_addowner_ok():
    data = getdata()
    host = get_host()
    user = data.users_group[0]
    channel = ch_create(data, user.token, '12345', True)
    user2 = data.users_group[2]
    ch_join_leave(data, user2.token, channel['channel_id'], 'join')

    ch_add_remove_owner(data, user.token, channel['channel_id'], user2.u_id,
                        'add')
    channel_profile = ch_details(data, user.token, channel['channel_id'], host)
    owner_list = channel_profile['owner_members']
    # Checking there is two owner in this channel
    assert owner_list[0]['u_id'] == user.u_id
    assert owner_list[1]['u_id'] == user2.u_id
示例#7
0
def test_channel_details_ok():
    data = getdata()
    host = get_host()
    user = data.users_group[0]
    # it takes in data, token, channel_name and is_public
    channel = ch_create(data, user.token, '12345', True)

    channel_profile = ch_details(data, user.token, channel['channel_id'], host)
    # Checking the output of channel detail
    assert channel_profile['name'] == "12345"

    owner_list = channel_profile["owner_members"]
    assert owner_list[0]['u_id'] == user.u_id

    member_list = channel_profile["all_members"]
    assert member_list[0]['u_id'] == user.u_id
示例#8
0
def test_channel_invite_ok():
    data = getdata()
    host = get_host()
    user = data.users_group[0]
    user1 = data.users_group[1]
    # it takes in data, token, channel_name and is_public
    channel = ch_create(data, user.token, '12345', True)
    # it takes in data, token, u_id and channel_id
    ch_invite(data, user.token, user1.u_id, channel['channel_id'])

    # Check the user is successfully added into channel
    # it takes in data, token and channel_id
    channel_profile = ch_details(data, user.token, channel['channel_id'], host)
    member_list = channel_profile['all_members']
    assert member_list[0]['u_id'] == user.u_id
    assert member_list[1]['u_id'] == user1.u_id
示例#9
0
def test_channel_leave_ok():
    data = getdata()
    host = get_host()
    user = data.users_group[0]
    user1 = data.users_group[1]
    # it takes in data, token, channel_name and is_public and return channel_id
    channel = ch_create(data, user.token, '12345', True)
    # user1 join to the channel
    ch_join_leave(data, user1.token, channel['channel_id'], 'join')
    # add user1 to be the owner of the channel
    ch_add_remove_owner(data, user.token, channel['channel_id'], user1.u_id,
                        'add')
    # user1 leave the channel
    ch_join_leave(data, user1.token, channel['channel_id'], 'leave')

    # Check the member in channel
    channel_profile = ch_details(data, user.token, channel['channel_id'], host)
    owner_list = channel_profile['owner_members']
    member_list = channel_profile['all_members']
    assert len(owner_list) == 1
    assert len(member_list) == 1