summaryrefslogtreecommitdiff
path: root/addons/portal/tests
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2017-01-10 09:41:50 +0100
committerThibault Delavallée <tde@odoo.com>2017-02-21 16:41:14 +0100
commit927fbe8845a91245b17d5834ea5ac6c95d62233d (patch)
treeb1709497272f57d9d2d3de7781420c73f904be74 /addons/portal/tests
parent80d26e26bba6cb3140e47eb4bb1933a5dfdbe144 (diff)
[IMP] mail: make tests less dependent on mail.channel model
Currently almost all mail tests run on mail.channel model. Indeed it is the only model inheriting from mail.thread and mail.alias when having only mail installed. However channel model have several specific features and is not totally a standard mail.thread model. For example notification recipients are computed a bit differently. Since 4f9105a4ef40bccd3b27a6a10cc612636a6499f7 mail module has a test model allowing to perform tests on a very simple mail.thread-like model. This commit make mail tests use this test model instead of mail.channel everywhere it is possible. Channel model should be used only when tests are channel-dependent.
Diffstat (limited to 'addons/portal/tests')
-rw-r--r--addons/portal/tests/test_portal.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/addons/portal/tests/test_portal.py b/addons/portal/tests/test_portal.py
index 083f5e87bed..774e2a6e328 100644
--- a/addons/portal/tests/test_portal.py
+++ b/addons/portal/tests/test_portal.py
@@ -8,16 +8,19 @@ from odoo.tools.misc import mute_logger
class TestPortal(TestMail):
def test_mail_compose_access_rights(self):
- self.group_pigs.write({'group_public_id': self.env.ref('base.group_portal').id})
- port_msg = self.group_pigs.message_post(body='Message')
+ test_channel = self.env['mail.channel'].create({
+ 'name': 'Pigs',
+ 'public': 'groups',
+ 'group_public_id': self.env.ref('base.group_portal').id})
+ port_msg = test_channel.message_post(body='Message')
# Do: Chell comments Pigs, ok because can write on it (public group)
- self.group_pigs.sudo(self.user_portal).message_post(body='I love Pigs', message_type='comment', subtype='mail.mt_comment')
+ test_channel.sudo(self.user_portal).message_post(body='I love Pigs', message_type='comment', subtype='mail.mt_comment')
# Do: Chell creates a mail.compose.message record on Pigs, because he uses the wizard
compose = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': 'mail.channel',
- 'default_res_id': self.group_pigs.id
+ 'default_res_id': test_channel.id
}).sudo(self.user_portal).create({
'subject': 'Subject',
'body': 'Body text',
@@ -35,7 +38,8 @@ class TestPortal(TestMail):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_invite_email_portal(self):
- group_pigs = self.group_pigs
+ test_record = self.env['mail.test'].create({'name': 'Pigs'})
+
base_url = self.env['ir.config_parameter'].get_param('web.base.url', default='')
# Carine Poilvache, with email, should receive emails for comments and emails
partner_carine = self.env['res.partner'].create({'name': 'Carine Poilvache', 'email': 'c@c'})
@@ -43,12 +47,12 @@ class TestPortal(TestMail):
# Do: create a mail_wizard_invite, validate it
self._init_mock_build_email()
mail_invite = self.env['mail.wizard.invite'].with_context({
- 'default_res_model': 'mail.channel',
- 'default_res_id': group_pigs.id}).create({
+ 'default_res_model': 'mail.test',
+ 'default_res_id': test_record.id}).create({
'partner_ids': [(4, partner_carine.id)], 'send_mail': True})
mail_invite.add_followers()
# Test: Pigs followers should contain Admin and Bert
- self.assertEqual(group_pigs.message_partner_ids, partner_carine)
+ self.assertIn(partner_carine, test_record.message_partner_ids)
# Test: partner must have been prepared for signup
# TDE FIXME: invite email for portal users should be fixed / improved / rethought
# self.assertTrue(partner_carine.signup_valid, 'partner has not been prepared for signup')
@@ -59,10 +63,10 @@ class TestPortal(TestMail):
self.assertEqual(len(self._mails), 1, 'sent email number incorrect, should be only for Bert')
for sent_email in self._mails:
self.assertEqual(
- sent_email.get('subject'), 'Invitation to follow Discussion channel: Pigs',
+ sent_email.get('subject'), 'Invitation to follow %s: Pigs' % self.env['mail.test']._description,
'invite: subject of invitation email is incorrect')
self.assertIn(
- 'Administrator invited you to follow Discussion channel document: Pigs', sent_email.get('body'),
+ 'Administrator invited you to follow %s document: Pigs' % self.env['mail.test']._description, sent_email.get('body'),
'invite: body of invitation email is incorrect')
# self.assertIn(
# partner_carine.signup_token, sent_email.get('body'),