예제 #1
0
def addowner_channel():
    response = request.get_json()
    token = response['token']
    channel_id = response['channel_id']
    u_id = response['u_id']
    channel_addowner(token, channel_id, u_id, da.USERS, da.CHANNEL)
    return dumps({})
예제 #2
0
def test_channel_addowner_twice():
    '''Function cannot add owner twice'''
    reset_data()
    data = auth_register('*****@*****.**', 'cs1531', 'Kevin', 'Trang')
    token = data['token']
    channel_id = channels_create(token, 'Channel One', True)
    data_two = auth_register('*****@*****.**', 'cs1531', 'Yena', 'Choi')
    other_user_id = data_two['u_id']
    channel_addowner(token, channel_id['channel_id'], other_user_id)
    with pytest.raises(InputError):
        channel_addowner(token, channel_id['channel_id'], other_user_id)
예제 #3
0
def test_channel_removeowner():
    '''Function should remove owner based on their u_id in specified channel'''
    reset_data()
    data = auth_register('*****@*****.**', 'cs1531', 'Kevin', 'Trang')
    token = data['token']
    channel_id = channels_create(token, 'Channel One', True)
    data_two = auth_register('*****@*****.**', 'cs1531', 'Yena', 'Choi')
    other_user_id = data_two['u_id']
    channel_addowner(token, channel_id['channel_id'], other_user_id)
    assert channel_removeowner(token, channel_id['channel_id'],
                               other_user_id) == {}
예제 #4
0
def test_channel_addowner_non_owner():
    '''Function cannot add owner to channel if authorised user is not owner'''
    reset_data()
    data = auth_register('*****@*****.**', 'cs1531', 'Kevin', 'Trang')
    token = data['token']
    channel_id = channels_create(token, 'Channel One', True)
    data_two = auth_register('*****@*****.**', 'cs1531', 'Yena', 'Choi')
    token_two = data_two['token']
    data_three = auth_register('*****@*****.**', 'cs1531', 'Yuri', 'Jo')
    other_user_id = data_three['u_id']
    with pytest.raises(AccessError):
        channel_addowner(token_two, channel_id['channel_id'], other_user_id)
예제 #5
0
def test_removeowner_authorised_non_owner():
    '''Function won't run if authorised user is not owner of channel'''
    reset_data()
    data = auth_register('*****@*****.**', 'cs1531', 'Kevin', 'Trang')
    token = data['token']
    channel_id = channels_create(token, 'Channel One', True)
    data_two = auth_register('*****@*****.**', 'cs1531', 'Yena', 'Choi')
    user_two_id = data_two['u_id']
    channel_addowner(token, channel_id['channel_id'], user_two_id)
    data_three = auth_register('*****@*****.**', 'cs1531', 'Yuri', 'Jo')
    token_three = data_three['token']
    with pytest.raises(AccessError):
        channel_removeowner(token_three, channel_id['channel_id'], user_two_id)
예제 #6
0
def addowner():
    '''User with u_id becomes an owner of the channel'''
    details = request.get_json()
    return dumps(
        channel_addowner(details['token'], details['channel_id'],
                         details['u_id']))