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_list_in_single_private_channel(create_user): testChannel = create(create_user['token'], "My Channel", False) assert list_(create_user['token']) == { 'channels': [{ 'channel_id': testChannel['channel_id'], 'name': 'My Channel' }] }
def test_list_in_absent_in_multiple_channels(create_user): id1 = create(create_user['token'], "My Channel", True)['channel_id'] id2 = create(create_user['token'], "My Channel2", True)['channel_id'] lev(create_user['token'], id1) lev(create_user['token'], id2) assert list_(create_user['token']) == {'channels': []}
def test_list_in_absent_in_channel(create_user): testChannel = create(create_user['token'], "My Channel", True) id = create(create_user['token'], "My Channel2", True)['channel_id'] lev(create_user['token'], id) assert list_(create_user['token']) == { 'channels': [{ 'channel_id': testChannel['channel_id'], 'name': 'My Channel' }] }
def test_list_in_two_channel(create_user): testChannel = create(create_user['token'], "My Channel", True) testChannel2 = create(create_user['token'], "My Channel2", True) assert list_(create_user['token']) == { 'channels': [{ 'channel_id': testChannel['channel_id'], 'name': 'My Channel' }, { 'channel_id': testChannel2['channel_id'], 'name': 'My Channel2' }] }
def test_list_no_channels(create_user): assert list_(create_user['token']) == {'channels': []}
def test_list_invalid_token(): with pytest.raises(AccessError): list_("NOT_VALID_TOKEN")
def chs_list(): return dumps(channels.list_(request.args.get('token')))