def test_mesasge_send_2(): """ Test the message_send function works as two message is send """ user_infor = auth_register("*****@*****.**", "ccc337992611", "Min", "Li") channel_infor = channels_create(user_infor['token'], 'test_one', True) time_create_date = datetime.datetime.now().replace(microsecond=0) time_create = time_create_date.timestamp() message_id_1 = message_send(user_infor['token'], channel_infor['channel_id'], 'a' * 99) message_id_2 = message_send(user_infor['token'], channel_infor['channel_id'], 'a' * 99) assert search(user_infor['token'], 'a' * 99) == { "messages": [{ 'message_id': message_id_2["message_id"], 'u_id': user_infor["u_id"], 'message': 'a' * 99, 'time_created': time_create, 'reacts': [set_reacts()], 'is_pinned': False }, { 'message_id': message_id_1["message_id"], 'u_id': user_infor["u_id"], 'message': 'a' * 99, 'time_created': time_create, 'reacts': [set_reacts()], 'is_pinned': False }] }
def test_message_send(): """ Assume that message could not be empty string. If empty string was sended The InputError should raisedcd test whether the message_send funtion worke as ervery input is correct. """ user_infor = auth_register("*****@*****.**", "ccc337992611", "Min", "Li") channel_infor = channels_create(user_infor['token'], 'test_one', True) time_create_date = datetime.datetime.now().replace(microsecond=0) time_create = time_create_date.timestamp() message_id = message_send(user_infor['token'], channel_infor['channel_id'], 'a' * 99) # To test that message actually exists. assert search(user_infor['token'], 'a' * 99) == { "messages": [{ 'message_id': message_id["message_id"], 'u_id': user_infor["u_id"], 'message': 'a' * 99, 'time_created': time_create, 'reacts': [set_reacts()], 'is_pinned': False }] } # the user_infor was return for test_search. return user_infor
def test_search_part_of_query(): """ test search function will also return a message that part of message match query. """ user_infor = auth.auth_register("*****@*****.**", "password", "Min", "Li") channel_infor = channels.channels_create(user_infor['token'], 'test_one', True) time_create_date = datetime.datetime.now().replace(microsecond=0) time_create = time_create_date.timestamp() message_id = message.message_send(user_infor['token'], channel_infor['channel_id'], 'a' * 99) assert other.search(user_infor['token'], 'a' * 98) == { "messages": [{ 'message_id': message_id["message_id"], 'u_id': user_infor["u_id"], 'message': 'a' * 99, 'time_created': time_create, 'reacts': [message_parser.set_reacts()], 'is_pinned': False }] }
def test_message_edit(): """ test message_edit worke under all authorid and valid input. """ user_info = auth_register("*****@*****.**", "ccc337992611", "Min", "Li") channel_info = channels_create(user_info['token'], 'test_one', True) msg_info = message_send_helper(user_info['token'], channel_info['channel_id'], "Test msg!") message_edit(user_info['token'], msg_info['msg_dict']['message_id'], 'a' * 97) assert search(user_info['token'], 'a' * 97) == { "messages": [{ 'message_id': msg_info['msg_dict']['message_id'], 'u_id': user_info['u_id'], 'message': 'a' * 97, 'time_created': msg_info['msg_time'], 'reacts': [set_reacts()], 'is_pinned': False }] }