Пример #1
0
def test_user_remove_own(reset):
    '''
    Invalid request to remove one's ownself
    '''
    admin_info, admin_token = register(
        '*****@*****.**', 'HelloWorld', 'Yousif', 'Wang')
    with pytest.raises(HTTPError):
        user_remove(admin_token, admin_info)
Пример #2
0
def test_user_remove_invalid_token(reset):
    '''
    test sending an invalid token
    '''
    _, token = register('*****@*****.**', 'HelloWorld', 'Yousif', 'Wang')
    u_id, _ = register('*****@*****.**', 'HelloWorld123', 'Josh', 'Wang')
    with pytest.raises(HTTPError):
        user_remove(token + 'a', u_id)
Пример #3
0
def test_user_remove_invalid_u_id(reset):
    '''
    removing a user who does not exist
    '''
    admin_id, token = register(
        '*****@*****.**', 'HelloWorld', 'Yousif', 'Wang')
    u_id, _ = register('*****@*****.**', 'HelloWorld123', 'Josh', 'Wang')
    with pytest.raises(HTTPError):
        user_remove(token, u_id + admin_id)
Пример #4
0
def test_user_remove_removed_from_channels(reset):
    '''
    removing a user should remove him from all channels he has joined
    '''
    _, admin_token = register(
        '*****@*****.**', 'HelloWorld', 'Yousif', 'Wang')
    u_id, u_token = register('*****@*****.**', 'HelloWorld123', 'Josh', 'Wang')
    # admin creates a channel
    channel_id = channels_create(admin_token, 'Da channel', is_public=True)
    # joining..
    channel_join(u_token, channel_id)
    # new user is removed
    user_remove(admin_token, u_id)
    # should only contain the admin now
    _, _, all_membs = channel_details(admin_token, channel_id)
    # 2 members since we have a hangman bot in each channel
    assert len(all_membs) == 2
Пример #5
0
def test_user_remove_removed_message(reset):
    '''
    A removed user has all the messages he has sent removed
    '''
    _, admin_token = register(
        '*****@*****.**', 'HelloWorld', 'Yousif', 'Wang')
    u_id, u_token = register('*****@*****.**', 'HelloWorld123', 'Josh', 'Wang')
    # admin creates a channel
    channel_id = channels_create(admin_token, 'Da channel', is_public=True)
    # joining..
    channel_join(u_token, channel_id)
    # send a message
    message_send(u_token, channel_id, 'HelloWorld')
    # new user is removed
    user_remove(admin_token, u_id)
    # their message should be removed from the channel
    messages, _, _ = channel_messages(admin_token, channel_id, start=0)
    # the reason we assert 1 is because the hangman sends a message at the
    # start of channel
    assert len(messages) == 1