Example #1
0
def test_channel_addowner_success(setup1, setup2, setup3):
    data = getData()
    reset_channels()
    ''' Creates a public channel (Admin: user1) '''
    channelsCreate1 = channels_create(setup1['token'], "Public Channel", True)
    channelId1 = channelsCreate1['channel_id']
    ''' User2 joins the channel '''
    channel_join(setup2['token'], channelId1)
    ''' Adds user2 as owner of "Public Channel" '''
    channel_addowner(setup1['token'], channelId1, setup2['u_id'])
    ''' If above line was succesful, will display user2 as an owner when calling channel_details '''
    details = channel_details(setup1['token'], channelId1)
    assert details['owner_members'] == [{
        'u_id':
        setup1['u_id'],
        'name_first':
        "Sojin",
        'name_last':
        "Nam",
        'profile_img_url':
        "https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/An_up-close_picture_of_a_curious_male_domestic_shorthair_tabby_cat.jpg/440px-An_up-close_picture_of_a_curious_male_domestic_shorthair_tabby_cat.jpg"
    }, {
        'u_id':
        setup2['u_id'],
        'name_first':
        "Fairuz",
        'name_last':
        "Alam",
        'profile_img_url':
        "https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/An_up-close_picture_of_a_curious_male_domestic_shorthair_tabby_cat.jpg/440px-An_up-close_picture_of_a_curious_male_domestic_shorthair_tabby_cat.jpg"
    }]
Example #2
0
def test_channel_addowner_not_a_member(setup1, setup2, setup3):
    data = getData()
    reset_channels()
    ''' Creates a public channel (Admin: user1) '''
    channelsCreate1 = channels_create(setup1['token'], "Public Channel", True)
    channelId1 = channelsCreate1['channel_id']
    ''' Error when owner tries to make a non-member an owner '''
    with pytest.raises(ValueError_http, match=r".*"):
        channel_addowner(setup1['token'], channelId1, setup2['u_id'])
Example #3
0
def test_channel_addowner_unauthorized_user(setup1, setup2, setup3):
    data = getData()
    reset_channels()
    ''' Creates a public channel (Admin: user1) '''
    channelsCreate1 = channels_create(setup1['token'], "Public Channel", True)
    channelId1 = channelsCreate1['channel_id']
    ''' Error when not-an-owner tries to add another user as an owner'''
    with pytest.raises(AccessError, match=r".*"):
        channel_addowner(setup2['token'], channelId1, setup1['u_id'])
Example #4
0
def test_channel_addowner_no_channel(setup1, setup2, setup3):
    data = getData()
    reset_channels()
    ''' Creates a public channel (Admin: user1) '''
    channelsCreate1 = channels_create(setup1['token'], "Public Channel", True)
    channelId1 = channelsCreate1['channel_id']
    ''' Error when channel does not exist '''
    with pytest.raises(ValueError_http, match=r".*"):
        channel_addowner(setup1['token'], -1, setup2['u_id'])
Example #5
0
def test_channel_addowner_already_owner(setup1, setup2, setup3):
    data = getData()
    reset_channels()
    ''' Creates a public channel (Admin: user1) '''
    channelsCreate1 = channels_create(setup1['token'], "Public Channel", True)
    channelId1 = channelsCreate1['channel_id']
    ''' User2 joins the channel '''
    channel_join(setup2['token'], channelId1)
    ''' Adds user2 as owner of "Public Channel" '''
    channel_addowner(setup1['token'], channelId1, setup2['u_id'])
    ''' Error when trying to add owner that is already an owner '''
    with pytest.raises(ValueError_http, match=r".*"):
        channel_addowner(setup1['token'], channelId1, setup2['u_id'])