Browse Source

Merge branch 'mail-addons-8.0-res_partner_mails_count' of github.com:yelizariev/addons-dev into mail-addons-8.0-res_partner_mails_count

pull/3/head
x620 9 years ago
parent
commit
5209f6d2f2
  1. 3
      res_partner_mails_count/tests/__init__.py
  2. 35
      res_partner_mails_count/tests/test_mail.py

3
res_partner_mails_count/tests/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_mail

35
res_partner_mails_count/tests/test_mail.py

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
from openerp.tests.common import TransactionCase
class test_message_count(TransactionCase):
post_install = True
def test_count(self):
new_partner1 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner one', 'email': 'tt@tt', 'notify_email': 'always'})
new_partner2 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner two', 'email': 'rr@rr', 'notify_email': 'always'})
self.assertEqual(new_partner1.mails_to, 0, 'rpmc: new partner have mails_to != 0')
mail_compose = self.env['mail.compose.message']
compose = mail_compose.with_context(
{
'default_composition_mode': 'comment',
'default_model': 'res.partner',
'default_res_id': new_partner1.id,
}).create(
{
'subject': 'test subj',
'body': 'test body',
'partner_ids': [(4, new_partner2.id)],
'email_from': 'tt@tt',
'author_id': new_partner1.id
})
compose.send_mail()
self.assertEqual(new_partner1.mails_to, 0)
self.assertEqual(new_partner1.mails_from, 1, 'rpmc: one message but mails_from != 1')
self.assertEqual(new_partner2.mails_to, 1, 'rpmc: one message but mails_to != 1')
self.assertEqual(new_partner2.mails_from, 0)
compose.send_mail()
self.assertEqual(new_partner1.mails_to, 0)
self.assertEqual(new_partner1.mails_from, 2, 'rpmc: one message but mails_from != 2')
self.assertEqual(new_partner2.mails_to, 2, 'rpmc: one message but mails_to != 2')
self.assertEqual(new_partner2.mails_from, 0)
Loading…
Cancel
Save