diff options
| author | Thibault Delavallée <tde@openerp.com> | 2013-04-26 15:28:47 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2013-04-26 15:28:47 +0200 |
| commit | b61c12d28ea18587fc3effd7d57ac655894dbd1a (patch) | |
| tree | 061aa1ce6431d44baec98ec3869da89347c885cf /addons/portal/tests | |
| parent | 0dada27fcd725291bc487e1f47434b0ddfef54b7 (diff) | |
[MERGE] Revisions 9000 ... 9002 of 7.0 branch
bzr revid: tde@openerp.com-20130426132847-mr8e0yuxao582bs6
Diffstat (limited to 'addons/portal/tests')
| -rw-r--r-- | addons/portal/tests/test_portal.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/addons/portal/tests/test_portal.py b/addons/portal/tests/test_portal.py index 07becf5cdd9..8021a0e371c 100644 --- a/addons/portal/tests/test_portal.py +++ b/addons/portal/tests/test_portal.py @@ -130,3 +130,70 @@ class test_portal(TestMailBase): 'invite: body of invitation email is incorrect') self.assertTrue(partner_carine.signup_url in sent_email.get('body'), 'invite: body of invitation email does not contain signup url') + + def test_20_notification_url(self): + """ Tests designed to test the URL added in notification emails. """ + cr, uid, group_pigs = self.cr, self.uid, self.group_pigs + + # Partner data + partner_raoul = self.res_partner.browse(cr, uid, self.partner_raoul_id) + partner_bert_id = self.res_partner.create(cr, uid, {'name': 'bert'}) + partner_bert = self.res_partner.browse(cr, uid, partner_bert_id) + # Mail data + mail_mail_id = self.mail_mail.create(cr, uid, {'state': 'exception'}) + mail = self.mail_mail.browse(cr, uid, mail_mail_id) + + # Test: link for nobody -> None + url = self.mail_mail._get_partner_access_link(cr, uid, mail) + self.assertEqual(url, None, + 'notification email: mails not send to a specific partner should not have any URL') + + # Test: link for partner -> signup URL + url = self.mail_mail._get_partner_access_link(cr, uid, mail, partner=partner_bert) + self.assertIn(partner_bert.signup_url, url, + 'notification email: mails send to a not-user partner should contain the signup URL') + + # Test: link for user -> signin + url = self.mail_mail._get_partner_access_link(cr, uid, mail, partner=partner_raoul) + self.assertIn('action=mail.action_mail_redirect', url, + 'notification email: link should contain the redirect action') + self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url, + 'notification email: link should contain the user login') + + @mute_logger('openerp.addons.mail.mail_thread', 'openerp.osv.orm') + def test_21_inbox_redirection(self): + """ Tests designed to test the inbox redirection of emails notification URLs. """ + cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs + model, act_id = self.ir_model_data.get_object_reference(cr, uid, 'mail', 'action_mail_inbox_feeds') + model, port_act_id = self.ir_model_data.get_object_reference(cr, uid, 'portal', 'action_mail_inbox_feeds_portal') + # Data: post a message on pigs + msg_id = self.group_pigs.message_post(body='My body', partner_ids=[self.partner_bert_id, self.partner_chell_id], type='comment', subtype='mail.mt_comment') + + # No specific parameters -> should redirect to Inbox + action = self.mail_thread.message_redirect_action(cr, self.user_raoul_id, {'params': {}}) + self.assertEqual(action.get('type'), 'ir.actions.client', + 'URL redirection: action without parameters should redirect to client action Inbox') + self.assertEqual(action.get('id'), act_id, + 'URL redirection: action without parameters should redirect to client action Inbox') + + # Bert has read access to Pigs -> should redirect to form view of Pigs + action = self.mail_thread.message_redirect_action(cr, self.user_raoul_id, {'params': {'message_id': msg_id}}) + self.assertEqual(action.get('type'), 'ir.actions.act_window', + 'URL redirection: action with message_id for read-accredited user should redirect to Pigs') + self.assertEqual(action.get('res_id'), group_pigs.id, + 'URL redirection: action with message_id for read-accredited user should redirect to Pigs') + + # Bert has no read access to Pigs -> should redirect to Inbox + action = self.mail_thread.message_redirect_action(cr, self.user_bert_id, {'params': {'message_id': msg_id}}) + self.assertEqual(action.get('type'), 'ir.actions.client', + 'URL redirection: action without parameters should redirect to client action Inbox') + self.assertEqual(action.get('id'), act_id, + 'URL redirection: action without parameters should redirect to client action Inbox') + + # Chell has no read access to pigs -> should redirect to Portal Inbox + action = self.mail_thread.message_redirect_action(cr, self.user_chell_id, {'params': {'message_id': msg_id}}) + self.assertEqual(action.get('type'), 'ir.actions.client', + 'URL redirection: action without parameters should redirect to client action Inbox') + self.assertEqual(action.get('id'), port_act_id, + 'URL redirection: action without parameters should redirect to client action Inbox') + |
