def test_channel_removeowner_7():
    owner_token, owner_id, u_token, u_id = setup()
    channel = channels_create(owner_token, "Channels Name", "true")
    channel_id = channel['channel_id']
    channel_join(u_token, channel_id)
    with pytest.raises(AccessError):
        channel_removeowner(u_token, channel_id, owner_id)
def test_channel_removeowner_4():
    owner_token, owner_id, u_token, u_id = setup()
    channel = channels_create(owner_token, "Channel Name", "true")
    channel_id = channel['channel_id']
    channel_join(u_token, channel_id)
    channel_addowner(owner_token, channel_id, u_id)
    channel_removeowner(owner_token, channel_id, u_id)
    with pytest.raises(ValueError):
        channel_removeowner(owner_token, channel_id, u_id)
def test_channel_removeowner_9():
    owner_token, owner_id, u_token, u_id = setup()
    channel = channels_create(owner_token, "Channel Name", "true")
    channel_id = channel['channel_id']
    channel_join(u_token, channel_id)
    channel_addowner(owner_token, channel_id, u_id)
    channel_removeowner(owner_token, channel_id, u_id)
    assert is_owner(u_id, channel_id) == 0
    assert is_owner(
        owner_id,
        channel_id) == 1  # Checking the owner has not been demoted as well
def test_channel_removeowner_10():
    owner_token, owner_id, u_token, u_id = setup()
    channel = channels_create(owner_token, "Channel Name", "true")
    channel_id = channel['channel_id']
    channel_join(u_token, channel_id)
    channel_addowner(owner_token, channel_id, u_id)
    assert is_owner(u_id, channel_id)
    channel_removeowner(owner_token, channel_id, u_id)
    assert is_owner(u_id, channel_id) == 0
    channel_addowner(owner_token, channel_id, u_id)
    assert is_owner(u_id, channel_id)
    channel_removeowner(owner_token, channel_id, u_id)
    assert is_owner(u_id, channel_id) == 0
def test_channel_removeowner_8():
    owner_token, owner_id, u_token, u_id = setup()
    channel = channels_create(owner_token, "Channels Name", "true")
    channel_id = channel['channel_id']
    channel_join(u_token, channel_id)
    # Creating a new member
    member_dict = auth_register("*****@*****.**", "password", "person",
                                "two")
    member_id = member_dict['u_id']
    member_token = member_dict['token']
    # End member setup
    channel_join(member_token, channel_id)
    with pytest.raises(ValueError):
        channel_removeowner(u_token, channel_id, member_id)