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.

33 lines
1.5 KiB

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