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_listall_in_single_channel(create_user):
    testChannel = create(create_user['token'], "My Channel", True)
    assert listall(create_user['token']) == {
        'channels': [{
            'channel_id': testChannel['channel_id'],
            'name': 'My Channel'
        }]
    }
def test_listall_in_absent_in_channel(create_user):

    testChannel = create(create_user['token'], "My Channel", True)
    testChannel2 = create(create_user['token'], "My Channel2", True)
    lev(create_user['token'], testChannel['channel_id'])
    assert listall(create_user['token']) == {
        'channels': [{
            'channel_id': testChannel['channel_id'],
            'name': 'My Channel'
        }, {
            'channel_id': testChannel2['channel_id'],
            'name': 'My Channel2'
        }]
    }
def test_listall_invalid_token():
    with pytest.raises(AccessError):
        listall("NOT_VALID_TOKEN")
def test_listall_in_single_private_channel(create_user):
    testChannel = create(create_user['token'], "My Channel", False)
    assert listall(create_user['token']) == {'channels': []}
def test_listall_no_channels(create_user):
    assert listall(create_user['token']) == {'channels': []}
Exemple #7
0
def chs_listall():
    return dumps(channels.listall(request.args.get('token')))