def test_message_send_many_characters(): BF.data['user_info'] = [] authRegisterDic = BF.user_register('*****@*****.**', '1234567', 'Andy', 'Wei') result = BF.channels_create(authRegisterDic['token'], 'good team', True) message = 'hello' * 1000 with pytest.raises(BF.ValueError): BF.message_send(authRegisterDic['token'], result['channel_id'], message)
def test_message_sendlater(): BF.data['user_info'] = [] BF.data['channel_info'] = [] BF.data['message_info'] = [] authRegisterDic = BF.user_register('*****@*****.**', '1234567', 'Andy', 'Wei') result = BF.channels_create(authRegisterDic['token'], 'good team', True) message = 'how are you' with pytest.raises(BF.ValueError): BF.sendlater_message(authRegisterDic['token'], result['channel_id'], message, 1242523) BF.data['channel_info'] = [] BF.data['message_info'] = [] BF.resetUser_id() BF.resetChannel_id() BF.resetMessage_id() authRegisterDict1 = BF.user_register('*****@*****.**', '123456', 'real', 'bot') token1 = authRegisterDict1['token'] channelsCreateDict = BF.channels_create(token1, 'Channel 1', True) channelID = channelsCreateDict['channel_id'] messageDict = BF.message_send(token1, channelID, "Hello World") invalidReactID = -420 with pytest.raises(BF.ValueError): BF.message_react(token1, messageDict['message_id'], invalidReactID)
def test_message_send_message_to_channel(): BF.data['user_info'] = [] BF.data['channel_info'] = [] authRegisterDic = BF.user_register('*****@*****.**', '1234567', 'Andy', 'Wei') result = BF.channels_create(authRegisterDic['token'], 'good team', True) message = 'how are you' result = BF.message_send(authRegisterDic['token'], result['channel_id'], message) BF.resetMessage_id() assert result['message_id'] == 1
def test_message_remove_valid(): BF.data['user_info'] = [] BF.data['channel_info'] = [] BF.data['message_info'] = [] BF.resetUser_id() BF.resetChannel_id() BF.resetMessage_id() authRegisterDict = BF.user_register('*****@*****.**', '123456', 'real', 'bot') token1 = authRegisterDict['token'] channelsCreateDict = BF.channels_create(token1, 'Channel 1', True) channelID = channelsCreateDict['channel_id'] messageDict = BF.message_send(token1, channelID, "Hello World") BF.message_remove(token1, messageDict['message_id'])
def test_message_unreact_no_active_react(): BF.data['user_info'] = [] BF.data['channel_info'] = [] BF.data['message_info'] = [] BF.resetUser_id() BF.resetChannel_id() BF.resetMessage_id() authRegisterDict1 = BF.user_register('*****@*****.**', '123456', 'real', 'bot') token1 = authRegisterDict1['token'] channelsCreateDict = BF.channels_create(token1, 'Channel 1', True) channelID = channelsCreateDict['channel_id'] messageDict = BF.message_send(token1, channelID, "Hello World") with pytest.raises(BF.ValueError): BF.message_unreact(token1, messageDict['message_id'], 1)
def test_message_pin_not_member(): BF.data['user_info'] = [] BF.data['channel_info'] = [] BF.data['message_info'] = [] BF.resetUser_id() BF.resetChannel_id() BF.resetMessage_id() authRegisterDict1 = BF.user_register('*****@*****.**', '123456', 'real', 'bot') token1 = authRegisterDict1['token'] authRegisterDict2 = BF.user_register('*****@*****.**', '1234567', 'real2', 'bot2') token2 = authRegisterDict2['token'] assert token1 != token2 channelsCreateDict = BF.channels_create(token1, 'Channel 1', False) channelID = channelsCreateDict['channel_id'] messageDict = BF.message_send(token1, channelID, "Hello World") with pytest.raises(BF.AccessError): BF.message_pin(token2, messageDict['message_id'])
def test_message_pin_not_admin(): BF.data['user_info'] = [] BF.data['channel_info'] = [] BF.data['message_info'] = [] BF.resetUser_id() BF.resetChannel_id() BF.resetMessage_id() authRegisterDict1 = BF.user_register('*****@*****.**', '123456', 'real', 'bot') token1 = authRegisterDict1['token'] authRegisterDict2 = BF.user_register('*****@*****.**', '123456', 'real', 'bot2') token2 = authRegisterDict2['token'] channelsCreateDict = BF.channels_create(token1, 'Channel 1', True) channelID = channelsCreateDict['channel_id'] BF.channel_join(token2, channelID) messageDict = BF.message_send(token1, channelID, "Hello World") with pytest.raises(BF.ValueError): BF.message_pin(token2, messageDict['message_id'])