diff options
| author | Thibault Delavallée <tde@odoo.com> | 2020-04-29 11:38:20 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-05-26 10:35:58 +0000 |
| commit | 4a2ac044f8bd4a5a1f96f0e45c008473dc15eec3 (patch) | |
| tree | 26d9b7406dadcbe299941f371803f363e6426946 /addons/mass_mailing/tests/common.py | |
| parent | a874dfa08abd5b3c54e29c0257dfa23118b910da (diff) | |
[IMP] (test_)(mass_)mail(_full): rename and reorganize mail related test classes
Modules holding tests and helpers
* link_tracker: mainly mock, asserts and tools for link tracker tests
(MockLinkTracker);
* mail: mainly gateway mock and base for mail tests
* MockEmail -> mocks for mail gateway;
* MailCase -> tools and asserts for mail tests;
* MailCommon -> base for mail functional tests);
* sms: mainly SMS gateway mock and base for sms tests
* MockSMS -> mocks for SMS gateway;
* SMS Case -> tools and asserts for mail / SMS tests;
* SMSCommon -> update of MailCommon with SMS capabilities);
* mass_mailing: mainly asserts and tools for mass mailing tests
* MassMailCase -> update of MailCase for mass mailing tools and asserts;
* MassMailCommon -> update of MailCommon with mass mailing);
* mass_mailing_sms: mainly asserts and tools for mass SMS tests
* MockMassSMS -> update of MockSMS for mass SMS tools and asserts;
* MassSMSCommon -> update of MassMailCommon with SMS capabilities);
Modules for tests
* test_mail: module for mail app tests (TestMailCommon);
* test_mass_mailing: module for mass mailing app tests (TestMassMailCommon);
* test_mail_full: tests integrating all discuss features, currently mainly
mail and SMS (TestMailFullCommon);
Enterprise: update test_mail_enterprise and test_marketing_automation
Task ID 2247037
Community PR odoo/odoo#50384
Enterprise PR odoo/enterprise#10266
Upgrade PR odoo/upgrade#1122
Diffstat (limited to 'addons/mass_mailing/tests/common.py')
| -rw-r--r-- | addons/mass_mailing/tests/common.py | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/addons/mass_mailing/tests/common.py b/addons/mass_mailing/tests/common.py index 9d49a5c5bcf..8c3925d7527 100644 --- a/addons/mass_mailing/tests/common.py +++ b/addons/mass_mailing/tests/common.py @@ -2,48 +2,11 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.addons.link_tracker.tests.common import MockLinkTracker -from odoo.addons.mail.tests.common import MailCase, mail_new_test_user -from odoo.tests.common import SavepointCase +from odoo.addons.mail.tests.common import MailCase, MailCommon, mail_new_test_user class MassMailCase(MailCase, MockLinkTracker): - def _find_mail_mail_wemail(self, email_to, state, author=None): - for mail in self._new_mails: - if author is not None and mail.author_id != author: - continue - if mail.state != state: - continue - if (mail.email_to == email_to and not mail.recipient_ids) or (not mail.email_to and mail.recipient_ids.email) == email_to: - break - else: - raise AssertionError('mail.mail not found for email_to %s / state %s in %s' % (email_to, state, repr([m.email_to for m in self._new_mails]))) - return mail - - def _find_mail_mail_wrecord(self, record): - for mail in self._new_mails: - if mail.model == record._name and mail.res_id == record.id: - break - else: - raise AssertionError('mail.mail not found for record %s in %s' % (record, repr([m.email_to for m in self._new_mails]))) - return mail - - def assertMailMailWEmails(self, emails, state, content, fields_values=None): - """ Will check in self._new_mails to find a sent mail.mail. To use with - mail gateway mock. - - :param emails: list of emails; - :param state: state of mail.mail; - :param content: content to check for each email; - :param fields_values: specific value to check on the mail.mail record; - """ - for email_to in emails: - sent_mail = self._find_mail_mail_wemail(email_to, state) - if content: - self.assertIn(content, sent_mail.body_html) - for fname, fvalue in (fields_values or {}).items(): - self.assertEqual(sent_mail[fname], fvalue) - def assertMailTraces(self, recipients_info, mailing, records, check_mail=True): """ Check content of traces. @@ -90,6 +53,8 @@ class MassMailCase(MailCase, MockLinkTracker): if state == 'sent': self.assertMailMailWEmails([email], 'sent', content, fields_values=fields_values) + elif state == 'replied': # replied imply something has been sent + self.assertMailMailWEmails([email], 'sent', content, fields_values=fields_values) elif state == 'ignored': self.assertMailMailWEmails([email], 'cancel', content, fields_values=fields_values) elif state == 'exception': @@ -100,11 +65,11 @@ class MassMailCase(MailCase, MockLinkTracker): raise NotImplementedError() -class TestMassMailCommon(SavepointCase, MassMailCase): +class MassMailCommon(MailCommon, MassMailCase): @classmethod def setUpClass(cls): - super(TestMassMailCommon, cls).setUpClass() + super(MassMailCommon, cls).setUpClass() cls.user_marketing = mail_new_test_user( cls.env, login='user_marketing', |
