'Testing private discussion between partners.'

@mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models', 'odoo.addons.mail.models.mail_mail')
def test_private_discussion(self):

    msg1_pids = [self.env.user.partner_id.id, self.partner_1.id]
    msg1 = self.env['mail.thread'].with_context({'thread_model': 'mail.channel'}).sudo(self.user_employee).message_post(partner_ids=msg1_pids, subtype='mail.mt_comment')
    msg = self.env['mail.message'].browse(msg1.id)
    self.assertEqual(msg.partner_ids, (self.env.user.partner_id | self.partner_1), 'message_post:    private    discussion:    incorrect    recipients')
    self.assertEqual(msg.model, False, 'message_post:    private    discussion:    context    key    "thread_model"    not    correctly    ignored    when    having    no    res_id')
    self.assertIn('openerp-private', msg.message_id, 'message_post:    private    discussion:    message-id    should    contain    the    private    keyword')
    self.format_and_process(MAIL_TEMPLATE, to='not_important@mydomain.com', email_from='valid.lelitre@agrolait.com', extra=('In-Reply-To:    %s' % msg.message_id), msg_id='<test30.JavaMail.0@agrolait.com>')
    msg2 = self.env['mail.message'].search([], limit=1)
    self.assertEqual(msg2.author_id, self.partner_1, 'message_post:    private    discussion:    wrong    author    through    mailgatewya    based    on    email')
    self.assertEqual(msg2.partner_ids, (self.user_employee.partner_id | self.env.user.partner_id), 'message_post:    private    discussion:    incorrect    recipients    when    replying')
    msg3 = self.env['mail.thread'].message_post(author_id=self.partner_1.id, parent_id=msg1.id, subtype='mail.mt_comment')
    msg = self.env['mail.message'].browse(msg3.id)
    self.assertEqual(msg.partner_ids, (self.user_employee.partner_id | self.env.user.partner_id), 'message_post:    private    discussion:    incorrect    recipients    when    replying')
    self.assertEqual(msg.needaction_partner_ids, (self.user_employee.partner_id | self.env.user.partner_id), 'message_post:    private    discussion:    incorrect    notified    recipients    when    replying')
