Exemplo n.º 1
0
def test_channel_details_unauthorized(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 authorized user is not a member of channel'''
    with pytest.raises(AccessError, match=r".*"):
        channel_details(setup2['token'], channelId1)
Exemplo n.º 2
0
def test_channel_details_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_details(setup1['token'], -1)
Exemplo n.º 3
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"
    }]
Exemplo n.º 4
0
def test_channel_details_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']

    assert channel_details(setup1['token'], channelId1) == {
        'name':
        "Public Channel",
        'all_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"
        }],
        '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"
        }]
    }