diff options
| author | Thibault Delavallée <tde@openerp.com> | 2015-06-11 16:04:39 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2015-07-09 11:13:03 +0200 |
| commit | d52bf613d6c7e6f2b66af7b95bc2cef4d8833cf9 (patch) | |
| tree | c2ba44bc10668afbc8215a912bdd434de2456c75 /addons/mail/tests/common.py | |
| parent | 4a818d84a5e4b1514d8ad1d0e34ffdc754934b40 (diff) | |
[CLEAN] mail: tests: reduce a bit the boilerplate of tests to lessen
the testing time.
Diffstat (limited to 'addons/mail/tests/common.py')
| -rw-r--r-- | addons/mail/tests/common.py | 65 |
1 files changed, 2 insertions, 63 deletions
diff --git a/addons/mail/tests/common.py b/addons/mail/tests/common.py index 42627e0f475..3ca45831f48 100644 --- a/addons/mail/tests/common.py +++ b/addons/mail/tests/common.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -import socket - from openerp.tests import common @@ -25,10 +23,10 @@ class TestMail(common.SavepointCase): super(TestMail, self).setUp() self._mails_args[:] = [] self._mails[:] = [] + @classmethod def setUpClass(cls): super(TestMail, cls).setUpClass() - cr, uid = cls.cr, cls.uid def build_email(self, *args, **kwargs): cls._mails_args.append(args) @@ -47,7 +45,7 @@ class TestMail(common.SavepointCase): user_group_public = cls.env.ref('base.group_public') # User Data: employee, noone - Users = cls.env['res.users'].with_context({'no_reset_password': True}) + Users = cls.env['res.users'].with_context({'no_reset_password': True, 'mail_create_nosubscribe': True}) cls.user_employee = Users.create({ 'name': 'Ernest Employee', 'login': 'ernest', @@ -56,22 +54,6 @@ class TestMail(common.SavepointCase): 'signature': '--\nErnest', 'notify_email': 'always', 'groups_id': [(6, 0, [user_group_employee.id])]}) - cls.user_employee_2 = Users.create({ - 'name': 'Raoul Grosbedon', - 'login': 'raoul', - 'alias_name': 'raoul', - 'email': 'r.g@example.com', - 'signature': 'SignRaoul', - 'notify_email': 'always', - 'groups_id': [(6, 0, [user_group_employee.id])]}) - cls.user_noone = Users.create({ - 'name': 'Noemie NoOne', - 'login': 'noemie', - 'alias_name': 'noemie', - 'email': 'n.n@example.com', - 'signature': '--\nNoemie', - 'notify_email': 'always', - 'groups_id': [(6, 0, [])]}) cls.user_public = Users.create({ 'name': 'Bert Tartignole', 'login': 'bert', @@ -89,20 +71,6 @@ class TestMail(common.SavepointCase): 'notify_email': 'always', 'groups_id': [(6, 0, [user_group_portal.id])]}) cls.user_admin = cls.env.user - # Update admin - # Set an email address for the user running the tests, used as Sender for outgoing mails - cls._company_name = 'TestCompany' - cls._admin_name = 'Administrator' - cls._admin_email = 'test@localhost' - cls.user_admin.write({ - 'email': cls._admin_email, - 'name': cls._admin_name, - 'signature': 'SignAdmin', - 'notify_email': 'always', - }) - cls.user_admin.company_id.write({ - 'name': cls._company_name, - }) # Test Data for Partners cls.partner_1 = cls.env['res.partner'].create({ @@ -136,35 +104,6 @@ class TestMail(common.SavepointCase): 'alias_name': 'public', 'alias_contact': 'everyone'} ).with_context({'mail_create_nosubscribe': False}) - # Private: private group - cls.group_private = TestMailGroup.create({ - 'name': 'Private', - 'public': 'private'} - ).with_context({'mail_create_nosubscribe': False}) - # Portal: group-based group using portal group - cls.group_portal = TestMailGroup.create({ - 'name': 'PigsPortal', - 'public': 'groups', - 'group_public_id': user_group_portal.id} - ).with_context({'mail_create_nosubscribe': False}) - - # groups@.. will cause the creation of new mail channels - cls.mail_channel_model = cls.env['ir.model'].search([('model', '=', 'mail.channel')], limit=1) - cls.alias = cls.env['mail.alias'].create({ - 'alias_name': 'groups', - 'alias_user_id': False, - 'alias_model_id': cls.mail_channel_model.id, - 'alias_contact': 'everyone'}) - - # Set a first message on public group to test update and hierarchy - cls.fake_email = cls.env['mail.message'].create({ - 'model': 'mail.channel', - 'res_id': cls.group_public.id, - 'subject': 'Public Discussion', - 'message_type': 'email', - 'author_id': cls.partner_1.id, - 'message_id': '<123456-openerp-%s-mail.group@%s>' % (cls.group_public.id, socket.gethostname()), - }) cls._init_mock_build_email() |
