def test_chadd02(validUser, owner):

    # For the slack owner
    with pt.raises(InputError):
        ch.add_owner(owner.details["token"], owner.real_channel["channel_id"],
                     owner.details["u_id"])

    # For secondary owners
    with pt.raises(InputError):
        ch.add_owner(owner.details["token"], owner.real_channel["channel_id"],
                     validUser.details2["u_id"])
class _owner(_validUser):

    # Register an owner
    details = register("*****@*****.**", "AmazingPassword", "Hyper",
                       "Swine")

    # Create a public channel
    real_channel = chs.create(details["token"], "CNN_aka_fake_news", True)

    # Create a private channel
    priv_channel = chs.create(details["token"], "Nine_News", False)

    # Send some messages
    msgs_ids = _send_messages(details, real_channel["channel_id"], 10)

    # Dictionary of all channels
    all_channels = chs.listall(details["token"])

    # Dictionary of channels you belong to
    some_channels = chs.list_(details["token"])

    # Dictionary of channel members
    ch_members = ch.det(details["token"], real_channel["channel_id"])

    # Add user as member
    ch.inv(details["token"], real_channel["channel_id"],
           _validUser.details_part_owner["u_id"])

    # Add another user as owner
    ch.add_owner(details["token"], real_channel["channel_id"],
                 _validUser.details_part_owner["u_id"])
def test_chadd00(validUser, owner):
    assert validUser.details2["u_id"] not in owner.ch_members["all_members"]
    ch.inv(owner.details["token"], owner.real_channel["channel_id"],
           validUser.details2["u_id"])
    assert ch.add_owner(owner.details["token"],
                        owner.real_channel["channel_id"],
                        validUser.details2["u_id"]) == {}
def test_chadd03(validUser, owner):
    with pt.raises(InputError):
        ch.add_owner(owner.details["token"], owner.real_channel["channel_id"],
                     validUser.details2["u_id"])
def test_chadd01(validUser, owner):
    with pt.raises(InputError):
        ch.add_owner(owner.details["token"], "INVALID_CHANNEL_ID",
                     validUser.details2["u_id"])
Exemple #6
0
def ch_add():
    data = request.get_json()
    return dumps(
        ch.add_owner(data["token"], int(data["channel_id"]), data["u_id"]))