From d626aa26b406bf65340f8a1e86968de273241ad1 Mon Sep 17 00:00:00 2001 From: Ilyas Date: Wed, 23 Mar 2016 17:27:28 +0500 Subject: [PATCH] [IMP] Add test --- res_partner_mails_count/tests/__init__.py | 22 ++++++++++++++ res_partner_mails_count/tests/test_mail.py | 35 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 res_partner_mails_count/tests/__init__.py create mode 100644 res_partner_mails_count/tests/test_mail.py diff --git a/res_partner_mails_count/tests/__init__.py b/res_partner_mails_count/tests/__init__.py new file mode 100644 index 0000000..0bc1d87 --- /dev/null +++ b/res_partner_mails_count/tests/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (C) 2013-Today OpenERP SA () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see +# +############################################################################## + +from . import test_mail diff --git a/res_partner_mails_count/tests/test_mail.py b/res_partner_mails_count/tests/test_mail.py new file mode 100644 index 0000000..4fc6383 --- /dev/null +++ b/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) \ No newline at end of file