Exemplo n.º 1
0
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"]) == {}
Exemplo n.º 2
0
def test_chlv00(validUser, owner):

    # Assume validUser1 not in channel yet
    ch.inv(owner.details["token"], owner.real_channel["channel_id"],
           validUser.details["u_id"])
    assert ch.lev(validUser.details["token"],
                  owner.real_channel["channel_id"]) == {}
Exemplo n.º 3
0
def test_chnv05(validUser, owner):

    # Check a non-existent token
    with pt.raises(AccessError) as e:
        ch.inv("INVALID_TOKEN", owner.real_channel["channel_id"],
               validUser.details["u_id"])
        print(f"As Expected {e}: Invalid Token")

    # Is the token in a valid format?
    with pt.raises(AccessError) as f:
        ch.inv(215125809, owner.real_channel["channel_id"],
               validUser.details["u_id"])
        print(f"As Expected {f}: Invalid format, int for token")
Exemplo n.º 4
0
def test_chnv00(validUser, owner):

    # Slack owner invites
    assert ch.inv(owner.details["token"], owner.real_channel["channel_id"],
                  validUser.details["u_id"]) == {}

    ch.lev(validUser.details["token"], owner.real_channel["channel_id"])

    # When a standard owner invites
    assert ch.inv(validUser.details_part_owner["token"],
                  owner.real_channel["channel_id"],
                  validUser.details["u_id"]) == {}

    ch.lev(validUser.details["token"], owner.real_channel["channel_id"])
Exemplo n.º 5
0
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"])
Exemplo n.º 6
0
def test_chnv04(validUser, owner):

    # Need to confirm that user is not in channel => make a secondary user with details2
    assert validUser.details2["u_id"] not in owner.ch_members["all_members"]
    with pt.raises(AccessError) as e:
        ch.inv(validUser.details2["token"], owner.real_channel["channel_id"],
               validUser.details["u_id"])
        print(
            f"As Expected {e}: A non-member cannot invite another non-member")

    with pt.raises(AccessError) as e:
        ch.inv(validUser.details2["token"], owner.real_channel["channel_id"],
               validUser.details2["u_id"])
        print(
            f"As Expected {e}: A non-member cannot invite the owner to his own channel"
        )
Exemplo n.º 7
0
def test_chnv02(validUser, owner):

    # Is user_id in valid format?
    with pt.raises(InputError) as e:
        ch.inv(owner.details["token"], owner.real_channel["channel_id"],
               "NOT_VALID_ID")
        print(f"As Expected {e}: User ID is invalid")

    with pt.raises(InputError) as f:
        # assuming user_id isnt longer than 12 digits
        ch.inv(owner.details["token"], owner.real_channel["channel_id"],
               1215279129507125)
        print(f"As Expected {f}: User ID is longer than 12 digits")

    with pt.raises(InputError) as g:
        # Does the function catch a float?
        ch.inv(owner.details["token"], owner.real_channel["channel_id"],
               42068.5)
        print(
            f"As Expected {g}: User ID cannot be represented as a floating point value"
        )
Exemplo n.º 8
0
def test_chnv01(validUser, owner):

    with pt.raises(InputError) as e:
        ch.inv(owner.details["token"], 'INVALID_CHANNEL_ID',
               validUser.details["u_id"])
        print(f"As Expected {e}: Channel ID is invalid")
Exemplo n.º 9
0
def ch_inv():
    data = request.get_json()
    return dumps(
        ch.inv(data["token"], int(data["channel_id"]), int(data["u_id"])))