You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp.tests.common import TransactionCase
  3. class test_message_count(TransactionCase):
  4. post_install = True
  5. def test_count(self):
  6. new_partner1 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner one', 'email': 'tt@tt', 'notify_email': 'always'})
  7. new_partner2 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner two', 'email': 'rr@rr', 'notify_email': 'always'})
  8. self.assertEqual(new_partner1.mails_to, 0, 'rpmc: new partner have mails_to != 0')
  9. mail_compose = self.env['mail.compose.message']
  10. compose = mail_compose.with_context(
  11. {
  12. 'default_composition_mode': 'comment',
  13. }).create(
  14. {
  15. 'subject': 'test subj',
  16. 'body': 'test body',
  17. 'partner_ids': [(4, new_partner2.id)],
  18. 'email_from': 'tt@tt',
  19. 'author_id': new_partner1.id
  20. })
  21. compose.send_mail()
  22. self.assertEqual(new_partner1.mails_to, 0)
  23. self.assertEqual(new_partner1.mails_from, 1, 'rpmc: one message but mails_from != 1')
  24. self.assertEqual(new_partner2.mails_to, 1, 'rpmc: one message but mails_to != 1')
  25. self.assertEqual(new_partner2.mails_from, 0)
  26. compose.send_mail()
  27. self.assertEqual(new_partner1.mails_to, 0)
  28. self.assertEqual(new_partner1.mails_from, 2, 'rpmc: one message but mails_from != 2')
  29. self.assertEqual(new_partner2.mails_to, 2, 'rpmc: one message but mails_to != 2')
  30. self.assertEqual(new_partner2.mails_from, 0)