def test_count_nb_message(self): """webmessage - count the number of messages""" 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(count_nb_messages(5), 3) delete_all_messages(5) self.assertEqual(count_nb_messages(5), 0)
def test_check_quota(self): """webmessage - you give a quota, it returns users over-quota""" webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi jekyll", msg_body="hello how are you?", ln=CFG_SITE_LANG) webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi jekyll", msg_body="hello how are you?", ln=CFG_SITE_LANG) webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi jekyll", msg_body="hello how are you?", ln=CFG_SITE_LANG) webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi jekyll", msg_body="hello how are you?", ln=CFG_SITE_LANG) d = check_quota(3) self.assertEqual(d.keys()[0], 2) delete_all_messages(2)
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_getting_nb_new_msg(self): """webmessage - count the nb of new message""" 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) self.assertEqual(get_nb_new_messages_for_user(5), 1)
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_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_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_delete_all(uid, confirmed=False, ln=CFG_SITE_LANG): """ Delete every message for a given user @param uid: user id (int) @param confirmed: 0 will produce a confirmation message @param ln: language @return: body with warnings """ infos = [] warnings = [] _ = gettext_set_language(ln) if confirmed: db.delete_all_messages(uid) infos = [_("Your mailbox has been emptied.")] return perform_request_display(uid, warnings, infos, ln) else: body = webmessage_templates.tmpl_confirm_delete(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)