Esempio n. 1
0
    def test_forward_parent_id(self):
        msg = self.test_record.sudo(self.user_employee).message_post(
            no_auto_thread=True, subtype='mail.mt_comment')
        self.assertNotIn(msg.model, msg.message_id)
        self.assertNotIn('-%d-' % msg.res_id, msg.message_id)
        self.assertIn('reply_to', msg.message_id)

        # forward it to a new thread AND an existing thread
        fw_msg_id = '<*****@*****.**>'
        fw_message = MAIL_TEMPLATE.format(to='*****@*****.**',
                                          cc='',
                                          subject='FW: Re: 1',
                                          email_from='*****@*****.**',
                                          extra='In-Reply-To: %s' %
                                          msg.message_id,
                                          msg_id=fw_msg_id)
        self.env['mail.thread'].message_process(None, fw_message)
        msg_fw = self.env['mail.message'].search([('message_id', '=',
                                                   fw_msg_id)])
        self.assertEqual(len(msg_fw), 1)
        new_record = self.env['mail.test.simple'].search([('name', "=",
                                                           msg_fw.subject)])
        self.assertEqual(len(new_record), 1)
        self.assertEqual(msg_fw.model, 'mail.test.simple')
        self.assertFalse(msg_fw.parent_id)
        self.assertTrue(msg_fw.res_id == new_record.id)
 def test_message_process(self):
     email_from = '*****@*****.**'
     to_email = '*****@*****.**'
     msg_id = 'Test log message to process'
     with self.assertRaises(ValueError):
         mail = MAIL_TEMPLATE.format(
             to=to_email,
             email_from=email_from,
             cc='',
             subject='testing',
             extra='',
             msg_id=msg_id,
         )
         self.env['mail.thread'].with_context({
             'fetchmail_server_id': self.fetchmail_server.id,
         }).message_process(None, mail)
Esempio n. 3
0
 def test_message_process(self):
     email_from = "*****@*****.**"
     to_email = "*****@*****.**"
     msg_id = "Test log message to process"
     with self.assertRaises(ValueError):
         mail = MAIL_TEMPLATE.format(
             to=to_email,
             email_from=email_from,
             cc="",
             subject="testing",
             extra="",
             msg_id=msg_id,
         )
         self.env["mail.thread"].with_context({
             "fetchmail_server_id":
             self.fetchmail_server.id
         }).message_process(None, mail)
Esempio n. 4
0
    def test_forward_parent_id(self):
        msg = self.test_record.sudo(self.user_employee).message_post(no_auto_thread=True, subtype='mail.mt_comment')
        self.assertNotIn(msg.model, msg.message_id)
        self.assertNotIn('-%d-' % msg.res_id, msg.message_id)
        self.assertIn('reply_to', msg.message_id)

        # forward it to a new thread AND an existing thread
        fw_msg_id = '<*****@*****.**>'
        fw_message = MAIL_TEMPLATE.format(to='*****@*****.**',
                                          cc='',
                                          subject='FW: Re: 1',
                                          email_from='*****@*****.**',
                                          extra='In-Reply-To: %s' % msg.message_id,
                                          msg_id=fw_msg_id)
        self.env['mail.thread'].message_process(None, fw_message)
        msg_fw = self.env['mail.message'].search([('message_id', '=', fw_msg_id)])
        self.assertEqual(len(msg_fw), 1)
        new_record = self.env['mail.test.simple'].search([('name', "=", msg_fw.subject)])
        self.assertEqual(len(new_record), 1)
        self.assertEqual(msg_fw.model, 'mail.test.simple')
        self.assertFalse(msg_fw.parent_id)
        self.assertTrue(msg_fw.res_id == new_record.id)