def test_setting_message_status(self): """webmessage - status from "new" to "read" """ # juliet writes the message to romeo webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) msgid = get_all_messages_for_user(5)[0][0] # status is changed set_message_status(5, msgid, 'R') msgstatus = get_all_messages_for_user(5)[0][5] self.assertEqual(msgstatus, 'R') webmessage.perform_request_delete_msg(5, msgid, ln=CFG_SITE_LANG)
def perform_request_display(uid, errors=[], warnings=[], infos=[], ln=CFG_SITE_LANG): """ Displays the user's Inbox @param uid: user id @return: a (body, [errors], [warnings]) formed tuple """ body = "" rows = [] rows = db.get_all_messages_for_user(uid) nb_messages = db.count_nb_messages(uid) no_quota_users = list_users_in_roles(CFG_WEBMESSAGE_ROLES_WITHOUT_QUOTA) no_quota = False if uid in no_quota_users: no_quota = True body = webmessage_templates.tmpl_display_inbox(messages=rows, infos=infos, warnings=warnings, nb_messages=nb_messages, no_quota=no_quota, ln=ln) return (body, errors, warnings)
def test_getting_all_messages_for_user(self): """webmessage - get all message for user""" delete_all_messages(5) # juliet writes 3 messages to romeo webmessage.perform_request_send( 6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG, ) webmessage.perform_request_send( 6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG, ) webmessage.perform_request_send( 6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG, ) self.assertEqual(len(get_all_messages_for_user(5)), 3) delete_all_messages(5)
def test_create_message(self): """webmessage - create msg but do not send it""" msgid = create_message(6, users_to_str="romeo", groups_to_str="montague-family", msg_subject="hello", msg_body="how are you", msg_send_on_date=datetext_default) send_message(5, msgid, status=CFG_WEBMESSAGE_STATUS_CODE['NEW']) result = get_all_messages_for_user(5) self.assertEqual(msgid, result[0][0] ) delete_all_messages(2)
def test_send_message(self): """webmessage - sending message using uid msgid""" #create a message to know the msgid msgid = create_message(6, users_to_str="romeo", groups_to_str="montague-family", msg_subject="hello", msg_body="how are you", msg_send_on_date=datetext_default) send_message(5, msgid, status=CFG_WEBMESSAGE_STATUS_CODE['NEW']) result = get_all_messages_for_user(5) self.assertEqual("hello", result[0][3]) webmessage.perform_request_delete_msg(5, result[0][0], ln=CFG_SITE_LANG)
def test_delete_message_from_user_inbox(self): """webmessage - delete message from user inbox""" delete_all_messages(5) # juliet writes a message to romeo webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) msg_id = get_all_messages_for_user(5)[0][0] delete_message_from_user_inbox(5, msg_id) self.assertEqual(count_nb_messages(5), 0)
def test_sending_message(self): """webmessage - send and receive a message""" # juliet writes the message to romeo webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) # it is verified that romeo received the message result = get_all_messages_for_user(5) self.assertEqual("Hi romeo", result[0][3]) self.assertEqual("juliet", result[0][2]) webmessage.perform_request_delete_msg(5, result[0][0], ln=CFG_SITE_LANG)
def test_getting_nb_readable_messages(self): """webmessage - get the nb of readable messages""" delete_all_messages(5) # juliet writes the message to romeo webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) msgid = get_all_messages_for_user(5)[0][0] # status is changed set_message_status(5, msgid, 'R') self.assertEqual(get_nb_readable_messages_for_user(5), 1) webmessage.perform_request_delete_msg(5, msgid, ln=CFG_SITE_LANG)
def perform_request_display(uid, warnings=[], infos=[], ln=CFG_SITE_LANG): """ Displays the user's Inbox @param uid: user id @return: body with warnings """ body = "" rows = [] rows = db.get_all_messages_for_user(uid) nb_messages = db.count_nb_messages(uid) no_quota_users = list_users_in_roles(CFG_WEBMESSAGE_ROLES_WITHOUT_QUOTA) no_quota = False if uid in no_quota_users: no_quota = True body = webmessage_templates.tmpl_display_inbox(messages=rows, infos=infos, warnings=warnings, nb_messages=nb_messages, no_quota=no_quota, ln=ln) return body
def test_getting_all_messages_for_user(self): """webmessage - get all message for user""" delete_all_messages(5) # juliet writes 3 messages to romeo webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) self.assertEqual(len(get_all_messages_for_user(5)), 3) delete_all_messages(5)