def test_channel_messages_unauthorized(setup1, setup2, setup3): data = getData() reset_channels() # Creates public channel (Admin: user1) channelsCreateDict1 = channels_create(setup1['token'], "Public Channel", True) channelId1 = channelsCreateDict1['channel_id'] # not a member of channel with pytest.raises(AccessError): channel_messages(setup2['token'], channelId1, 1)
def test_channel_messages_no_channel(setup1, setup2, setup3): data = getData() reset_channels() # Creates public channel (Admin: user1) channelsCreateDict1 = channels_create(setup1['token'], "Public Channel", True) channelId1 = channelsCreateDict1['channel_id'] # channel doesnt exist with pytest.raises(ValueError_http): channel_messages(setup1['token'], -1, 10)
def test_channel_messages_start_equal(setup1, setup2, setup3): data = getData() reset_channels() # Creates public channel (Admin: user1) channelsCreateDict1 = channels_create(setup1['token'], "Public Channel", True) channelId1 = channelsCreateDict1['channel_id'] message_send(setup1['token'], channelId1, 'sendmessage') # start is equal to total messages with pytest.raises(ValueError_http): channel_messages(setup1['token'], channelId1, 1)
def test_channel_messages_success_less_than_fifty(setup1, setup2, setup3): data = getData() reset_channels() # Creates public channel (Admin: user1) channelsCreateDict1 = channels_create(setup1['token'], "Public Channel", True) channelId1 = channelsCreateDict1['channel_id'] i = 0 message_send(setup1['token'], channelId1, 'oldest') while i < 30: message_send(setup1['token'], channelId1, 'hello') i += 1 message_send(setup1['token'], channelId1, 'recent') assert len(channel_messages(setup1['token'], channelId1, 1)['messages']) == 31 assert channel_messages(setup1['token'], channelId1, 1)['messages'][0]['message'] == 'hello' assert channel_messages(setup1['token'], channelId1, 1)['messages'][30]['message'] == 'oldest'
def test_channel_messages_no_message(setup1, setup2, setup3): data = getData() reset_channels() # Creates public channel (Admin: user1) channelsCreateDict1 = channels_create(setup1['token'], "Public Channel", True) channelId1 = channelsCreateDict1['channel_id'] assert channel_messages(setup1['token'], channelId1, 0) == { 'messages': [], 'start': 0, 'end': 0 }