diff options
Diffstat (limited to 'addons/mail/tests')
| -rw-r--r-- | addons/mail/tests/test_mail_base.py | 6 | ||||
| -rw-r--r-- | addons/mail/tests/test_mail_features.py | 6 | ||||
| -rw-r--r-- | addons/mail/tests/test_mail_gateway.py | 230 |
3 files changed, 127 insertions, 115 deletions
diff --git a/addons/mail/tests/test_mail_base.py b/addons/mail/tests/test_mail_base.py index 7ca8b93135c..b0f9f72b6f7 100644 --- a/addons/mail/tests/test_mail_base.py +++ b/addons/mail/tests/test_mail_base.py @@ -71,9 +71,9 @@ class TestMailBase(common.TransactionCase): # Test users to use through the various tests self.res_users.write(cr, uid, uid, {'name': 'Administrator'}) self.user_raoul_id = self.res_users.create(cr, uid, - {'name': 'Raoul Grosbedon', 'signature': 'SignRaoul', 'email': 'raoul@raoul.fr', 'login': 'raoul', 'groups_id': [(6, 0, [self.group_employee_id])]}) + {'name': 'Raoul Grosbedon', 'signature': 'SignRaoul', 'email': 'raoul@raoul.fr', 'login': 'raoul', 'alias_name': 'raoul', 'groups_id': [(6, 0, [self.group_employee_id])]}) self.user_bert_id = self.res_users.create(cr, uid, - {'name': 'Bert Tartignole', 'signature': 'SignBert', 'email': 'bert@bert.fr', 'login': 'bert', 'groups_id': [(6, 0, [])]}) + {'name': 'Bert Tartignole', 'signature': 'SignBert', 'email': 'bert@bert.fr', 'login': 'bert', 'alias_name': 'bert', 'groups_id': [(6, 0, [])]}) self.user_raoul = self.res_users.browse(cr, uid, self.user_raoul_id) self.user_bert = self.res_users.browse(cr, uid, self.user_bert_id) self.user_admin = self.res_users.browse(cr, uid, uid) @@ -83,7 +83,7 @@ class TestMailBase(common.TransactionCase): # Test 'pigs' group to use through the various tests self.group_pigs_id = self.mail_group.create(cr, uid, - {'name': 'Pigs', 'description': 'Fans of Pigs, unite !'}, + {'name': 'Pigs', 'description': 'Fans of Pigs, unite !', 'alias_name': 'group+pigs'}, {'mail_create_nolog': True}) self.group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) diff --git a/addons/mail/tests/test_mail_features.py b/addons/mail/tests/test_mail_features.py index ca9c156c8cb..91ede8b8449 100644 --- a/addons/mail/tests/test_mail_features.py +++ b/addons/mail/tests/test_mail_features.py @@ -32,17 +32,17 @@ class test_mail(TestMailBase): """ Test basic mail.alias setup works, before trying to use them for routing """ cr, uid = self.cr, self.uid self.user_valentin_id = self.res_users.create(cr, uid, - {'name': 'Valentin Cognito', 'email': 'valentin.cognito@gmail.com', 'login': 'valentin.cognito'}) + {'name': 'Valentin Cognito', 'email': 'valentin.cognito@gmail.com', 'login': 'valentin.cognito', 'alias_name': 'valentin.cognito'}) self.user_valentin = self.res_users.browse(cr, uid, self.user_valentin_id) self.assertEquals(self.user_valentin.alias_name, self.user_valentin.login, "Login should be used as alias") self.user_pagan_id = self.res_users.create(cr, uid, - {'name': 'Pagan Le Marchant', 'email': 'plmarchant@gmail.com', 'login': 'plmarchant@gmail.com'}) + {'name': 'Pagan Le Marchant', 'email': 'plmarchant@gmail.com', 'login': 'plmarchant@gmail.com', 'alias_name': 'plmarchant@gmail.com'}) self.user_pagan = self.res_users.browse(cr, uid, self.user_pagan_id) self.assertEquals(self.user_pagan.alias_name, 'plmarchant', "If login is an email, the alias should keep only the local part") self.user_barty_id = self.res_users.create(cr, uid, - {'name': 'Bartholomew Ironside', 'email': 'barty@gmail.com', 'login': 'b4r+_#_R3wl$$'}) + {'name': 'Bartholomew Ironside', 'email': 'barty@gmail.com', 'login': 'b4r+_#_R3wl$$', 'alias_name': 'b4r+_#_R3wl$$'}) self.user_barty = self.res_users.browse(cr, uid, self.user_barty_id) self.assertEquals(self.user_barty.alias_name, 'b4r+_-_r3wl-', 'Disallowed chars should be replaced by hyphens') diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py index 9e05bb049c1..2e0ba336dc4 100644 --- a/addons/mail/tests/test_mail_gateway.py +++ b/addons/mail/tests/test_mail_gateway.py @@ -99,20 +99,20 @@ class TestMailgateway(TestMailBase): # -------------------------------------------------- # Do: find partner with email -> first partner should be found - partner_info = self.mail_thread.message_find_partner_from_emails(cr, uid, None, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0] + partner_info = self.mail_thread.message_partner_info_from_emails(cr, uid, None, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0] self.assertEqual(partner_info['full_name'], 'Maybe Raoul <test@test.fr>', - 'mail_thread: message_find_partner_from_emails did not handle email') + 'mail_thread: message_partner_info_from_emails did not handle email') self.assertEqual(partner_info['partner_id'], p_a_id, - 'mail_thread: message_find_partner_from_emails wrong partner found') + 'mail_thread: message_partner_info_from_emails wrong partner found') # Data: add some data about partners # 2 - User BRaoul p_b_id = self.res_partner.create(cr, uid, {'name': 'BRaoul', 'email': 'test@test.fr', 'user_ids': [(4, user_raoul.id)]}) # Do: find partner with email -> first user should be found - partner_info = self.mail_thread.message_find_partner_from_emails(cr, uid, None, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0] + partner_info = self.mail_thread.message_partner_info_from_emails(cr, uid, None, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0] self.assertEqual(partner_info['partner_id'], p_b_id, - 'mail_thread: message_find_partner_from_emails wrong partner found') + 'mail_thread: message_partner_info_from_emails wrong partner found') # -------------------------------------------------- # CASE1: with object @@ -120,9 +120,9 @@ class TestMailgateway(TestMailBase): # Do: find partner in group where there is a follower with the email -> should be taken self.mail_group.message_subscribe(cr, uid, [group_pigs.id], [p_b_id]) - partner_info = self.mail_group.message_find_partner_from_emails(cr, uid, group_pigs.id, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0] + partner_info = self.mail_group.message_partner_info_from_emails(cr, uid, group_pigs.id, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0] self.assertEqual(partner_info['partner_id'], p_b_id, - 'mail_thread: message_find_partner_from_emails wrong partner found') + 'mail_thread: message_partner_info_from_emails wrong partner found') def test_05_mail_message_mail_mail(self): """ Tests designed for testing email values based on mail.message, aliases, ... """ @@ -189,6 +189,7 @@ class TestMailgateway(TestMailBase): # Data: set catchall domain self.registry('ir.config_parameter').set_param(cr, uid, 'mail.catchall.domain', alias_domain) + self.registry('ir.config_parameter').unlink(cr, uid, self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.alias')])) # Update message self.mail_message.write(cr, user_raoul_id, [msg_id], {'email_from': False, 'reply_to': False}) @@ -220,87 +221,6 @@ class TestMailgateway(TestMailBase): self.assertEqual(mail.reply_to, msg.email_from, 'mail_mail: incorrect reply_to: should be message email_from') - def test_05_mail_message_mail_mail(self): - """ Tests designed for testing email values based on mail.message, aliases, ... """ - cr, uid = self.cr, self.uid - - # Data: clean catchall domain - param_ids = self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.domain')]) - self.registry('ir.config_parameter').unlink(cr, uid, param_ids) - - # Do: create a mail_message with a reply_to, without message-id - msg_id = self.mail_message.create(cr, uid, {'subject': 'Subject', 'body': 'Body', 'reply_to': 'custom@example.com'}) - msg = self.mail_message.browse(cr, uid, msg_id) - # Test: message content - self.assertIn('reply_to', msg.message_id, - 'mail_message: message_id should be specific to a mail_message with a given reply_to') - self.assertEqual('custom@example.com', msg.reply_to, - 'mail_message: incorrect reply_to') - # Do: create a mail_mail with the previous mail_message and specified reply_to - mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'reply_to': 'other@example.com', 'state': 'cancel'}) - mail = self.mail_mail.browse(cr, uid, mail_id) - # Test: mail_mail content - self.assertEqual(mail.reply_to, 'other@example.com', - 'mail_mail: reply_to should be equal to the one coming from creation values') - # Do: create a mail_mail with the previous mail_message - self.mail_message.write(cr, uid, [msg_id], {'reply_to': 'custom@example.com'}) - msg.refresh() - mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'state': 'cancel'}) - mail = self.mail_mail.browse(cr, uid, mail_id) - # Test: mail_mail content - self.assertEqual(mail.reply_to, msg.reply_to, - 'mail_mail: reply_to should be equal to the one coming from the mail_message') - - # Do: create a mail_message without a reply_to - msg_id = self.mail_message.create(cr, uid, {'subject': 'Subject', 'body': 'Body', 'model': 'mail.group', 'res_id': self.group_pigs_id, 'email_from': False}) - msg = self.mail_message.browse(cr, uid, msg_id) - # Test: message content - self.assertIn('mail.group', msg.message_id, - 'mail_message: message_id should contain model') - self.assertIn('%s' % self.group_pigs_id, msg.message_id, - 'mail_message: message_id should contain res_id') - self.assertFalse(msg.reply_to, - 'mail_message: should not generate a reply_to address when not specified') - # Do: create a mail_mail based on the previous mail_message - mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'state': 'cancel'}) - mail = self.mail_mail.browse(cr, uid, mail_id) - # Test: mail_mail content - self.assertFalse(mail.reply_to, - 'mail_mail: reply_to should not have been guessed') - # Update message - self.mail_message.write(cr, uid, [msg_id], {'email_from': 'someone@example.com'}) - msg.refresh() - # Do: create a mail_mail based on the previous mail_message - mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'state': 'cancel'}) - mail = self.mail_mail.browse(cr, uid, mail_id) - # Test: mail_mail content - self.assertEqual(email_split(mail.reply_to), email_split(msg.email_from), - 'mail_mail: reply_to should be equal to mail_message.email_from when having no document or default alias') - - # Data: set catchall domain - self.registry('ir.config_parameter').set_param(cr, uid, 'mail.catchall.domain', 'schlouby.fr') - self.registry('ir.config_parameter').unlink(cr, uid, self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.alias')])) - - # Update message - self.mail_message.write(cr, uid, [msg_id], {'email_from': False, 'reply_to': False}) - msg.refresh() - # Do: create a mail_mail based on the previous mail_message - mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'state': 'cancel'}) - mail = self.mail_mail.browse(cr, uid, mail_id) - # Test: mail_mail content - self.assertEqual(mail.reply_to, '"Followers of Pigs" <group+pigs@schlouby.fr>', - 'mail_mail: reply_to should equal the mail.group alias') - - # Update message - self.mail_message.write(cr, uid, [msg_id], {'res_id': False, 'email_from': 'someone@schlouby.fr', 'reply_to': False}) - msg.refresh() - # Do: create a mail_mail based on the previous mail_message - mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'state': 'cancel'}) - mail = self.mail_mail.browse(cr, uid, mail_id) - # Test: mail_mail content - self.assertEqual(mail.reply_to, msg.email_from, - 'mail_mail: reply_to should equal the mail_message email_from') - # Data: set catchall alias self.registry('ir.config_parameter').set_param(self.cr, self.uid, 'mail.catchall.alias', 'gateway') @@ -310,7 +230,7 @@ class TestMailgateway(TestMailBase): # Do: create a mail_mail based on the previous mail_message mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'state': 'cancel'}) mail = self.mail_mail.browse(cr, uid, mail_id) - # Test: mail_mail content + # Test: mail_mail Content-Type self.assertEqual(mail.reply_to, 'gateway@schlouby.fr', 'mail_mail: reply_to should equal the catchall email alias') @@ -351,7 +271,10 @@ class TestMailgateway(TestMailBase): alias_id = self.mail_alias.create(cr, uid, { 'alias_name': 'groups', 'alias_user_id': False, - 'alias_model_id': self.mail_group_model_id}) + 'alias_model_id': self.mail_group_model_id, + 'alias_parent_model_id': self.mail_group_model_id, + 'alias_parent_thread_id': self.group_pigs_id, + 'alias_contact': 'everyone'}) # -------------------------------------------------- # Test1: new record creation @@ -392,12 +315,42 @@ class TestMailgateway(TestMailBase): # Data: unlink group frog_group.unlink() - # Do: incoming email from a known partner on an alias with known recipients, alias is owned by user that can create a group - self.mail_alias.write(cr, uid, [alias_id], {'alias_user_id': self.user_raoul_id}) + # Do: incoming email from an unknown partner on a Partners only alias -> bounce + self._init_mock_build_email() + self.mail_alias.write(cr, uid, [alias_id], {'alias_contact': 'partners'}) + frog_groups = format_and_process(MAIL_TEMPLATE, to='groups@example.com, other2@gmail.com') + # Test: no group created + self.assertTrue(len(frog_groups) == 0) + # Test: email bounced + sent_emails = self._build_email_kwargs_list + self.assertEqual(len(sent_emails), 1, + 'message_process: incoming email on Partners alias should send a bounce email') + self.assertIn('Frogs', sent_emails[0].get('subject'), + 'message_process: bounce email on Partners alias should contain the original subject') + self.assertIn('test.sylvie.lelitre@agrolait.com', sent_emails[0].get('email_to'), + 'message_process: bounce email on Partners alias should have original email sender as recipient') + + # Do: incoming email from an unknown partner on a Followers only alias -> bounce + self._init_mock_build_email() + self.mail_alias.write(cr, uid, [alias_id], {'alias_contact': 'followers'}) + frog_groups = format_and_process(MAIL_TEMPLATE, to='groups@example.com, other3@gmail.com') + # Test: no group created + self.assertTrue(len(frog_groups) == 0) + # Test: email bounced + sent_emails = self._build_email_kwargs_list + self.assertEqual(len(sent_emails), 1, + 'message_process: incoming email on Followers alias should send a bounce email') + self.assertIn('Frogs', sent_emails[0].get('subject'), + 'message_process: bounce email on Followers alias should contain the original subject') + self.assertIn('test.sylvie.lelitre@agrolait.com', sent_emails[0].get('email_to'), + 'message_process: bounce email on Followers alias should have original email sender as recipient') + + # Do: incoming email from a known partner on a Partners alias -> ok (+ test on alias.user_id) + self.mail_alias.write(cr, uid, [alias_id], {'alias_user_id': self.user_raoul_id, 'alias_contact': 'partners'}) p1id = self.res_partner.create(cr, uid, {'name': 'Sylvie Lelitre', 'email': 'test.sylvie.lelitre@agrolait.com'}) - p2id = self.res_partner.create(cr, uid, {'name': 'Other Poilvache', 'email': 'other@gmail.com'}) + p2id = self.res_partner.create(cr, uid, {'name': 'Other Poilvache', 'email': 'other4@gmail.com'}) self._init_mock_build_email() - frog_groups = format_and_process(MAIL_TEMPLATE, to='groups@example.com, other@gmail.com') + frog_groups = format_and_process(MAIL_TEMPLATE, to='groups@example.com, other4@gmail.com') sent_emails = self._build_email_kwargs_list # Test: one group created by Raoul self.assertEqual(len(frog_groups), 1, 'message_process: a new mail.group should have been created') @@ -409,24 +362,37 @@ class TestMailgateway(TestMailBase): self.assertEqual(len(frog_group.message_ids), 1, 'message_process: newly created group should have the incoming email in message_ids') msg = frog_group.message_ids[0] - # Test: message: unknown email address -> message has email_from, not author_id + # Test: message: author found self.assertEqual(p1id, msg.author_id.id, 'message_process: message on created group should have Sylvie as author_id') self.assertIn('Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>', msg.email_from, 'message_process: message on created group should have have an email_from') - # Test: author (not recipient and not raoul (as alias owner)) added as follower + # Test: author (not recipient and not Raoul (as alias owner)) added as follower frog_follower_ids = set([p.id for p in frog_group.message_follower_ids]) self.assertEqual(frog_follower_ids, set([p1id]), 'message_process: newly created group should have 1 follower (author, not creator, not recipients)') # Test: sent emails: no-one, no bounce effet + sent_emails = self._build_email_kwargs_list self.assertEqual(len(sent_emails), 0, 'message_process: should not bounce incoming emails') # Data: unlink group frog_group.unlink() - # Do: incoming email from a known partner that is also an user that can create a mail.group - self.res_users.create(cr, uid, {'partner_id': p1id, 'login': 'sylvie', 'groups_id': [(6, 0, [self.group_employee_id])]}) - frog_groups = format_and_process(MAIL_TEMPLATE, to='groups@example.com, other@gmail.com') + # Do: incoming email from a not follower Partner on a Followers only alias -> bounce + self._init_mock_build_email() + self.mail_alias.write(cr, uid, [alias_id], {'alias_user_id': False, 'alias_contact': 'followers'}) + frog_groups = format_and_process(MAIL_TEMPLATE, to='groups@example.com, other5@gmail.com') + # Test: no group created + self.assertTrue(len(frog_groups) == 0) + # Test: email bounced + sent_emails = self._build_email_kwargs_list + self.assertEqual(len(sent_emails), 1, + 'message_process: incoming email on Partners alias should send a bounce email') + + # Do: incoming email from a parent document follower on a Followers only alias -> ok + self._init_mock_build_email() + self.mail_group.message_subscribe(cr, uid, [self.group_pigs_id], [p1id]) + frog_groups = format_and_process(MAIL_TEMPLATE, to='groups@example.com, other6@gmail.com') # Test: one group created by Raoul (or Sylvie maybe, if we implement it) self.assertEqual(len(frog_groups), 1, 'message_process: a new mail.group should have been created') frog_group = self.mail_group.browse(cr, uid, frog_groups[0]) @@ -438,15 +404,63 @@ class TestMailgateway(TestMailBase): self.assertEqual(frog_follower_ids, set([p1id]), 'message_process: newly created group should have 1 follower (author, not creator, not recipients)') # Test: sent emails: no-one, no bounce effet + sent_emails = self._build_email_kwargs_list self.assertEqual(len(sent_emails), 0, 'message_process: should not bounce incoming emails') # -------------------------------------------------- - # Test2: discussion update + # Test2: update-like alias + # -------------------------------------------------- + + # Do: Pigs alias is restricted, should bounce + self._init_mock_build_email() + self.mail_group.write(cr, uid, [frog_group.id], {'alias_name': 'frogs', 'alias_contact': 'followers', 'alias_force_thread_id': frog_group.id}) + frog_groups = format_and_process(MAIL_TEMPLATE, email_from='other4@gmail.com', + msg_id='<1198923581.41972151344608186760.JavaMail.diff1@agrolait.com>', + to='frogs@example.com>', subject='Re: news') + # Test: no group 'Re: news' created, still only 1 Frogs group + self.assertEqual(len(frog_groups), 0, + 'message_process: reply on Frogs should not have created a new group with new subject') + frog_groups = self.mail_group.search(cr, uid, [('name', '=', 'Frogs')]) + self.assertEqual(len(frog_groups), 1, + 'message_process: reply on Frogs should not have created a duplicate group with old subject') + frog_group = self.mail_group.browse(cr, uid, frog_groups[0]) + # Test: email bounced + sent_emails = self._build_email_kwargs_list + self.assertEqual(len(sent_emails), 1, + 'message_process: incoming email on Followers alias should send a bounce email') + self.assertIn('Re: news', sent_emails[0].get('subject'), + 'message_process: bounce email on Followers alias should contain the original subject') + + # Do: Pigs alias is restricted, should accept Followers + self._init_mock_build_email() + self.mail_group.message_subscribe(cr, uid, [frog_group.id], [p2id]) + frog_groups = format_and_process(MAIL_TEMPLATE, email_from='other4@gmail.com', + msg_id='<1198923581.41972151344608186799.JavaMail.diff1@agrolait.com>', + to='frogs@example.com>', subject='Re: cats') + # Test: no group 'Re: news' created, still only 1 Frogs group + self.assertEqual(len(frog_groups), 0, + 'message_process: reply on Frogs should not have created a new group with new subject') + frog_groups = self.mail_group.search(cr, uid, [('name', '=', 'Frogs')]) + self.assertEqual(len(frog_groups), 1, + 'message_process: reply on Frogs should not have created a duplicate group with old subject') + frog_group = self.mail_group.browse(cr, uid, frog_groups[0]) + # Test: one new message + self.assertEqual(len(frog_group.message_ids), 2, 'message_process: group should contain 2 messages after reply') + # Test: sent emails: 1 (Sylvie copy of the incoming email, but no bounce) + sent_emails = self._build_email_kwargs_list + self.assertEqual(len(sent_emails), 1, + 'message_process: one email should have been generated') + self.assertIn('test.sylvie.lelitre@agrolait.com', sent_emails[0].get('email_to')[0], + 'message_process: email should be sent to Sylvie') + self.mail_group.message_unsubscribe(cr, uid, [frog_group.id], [p2id]) + + # -------------------------------------------------- + # Test3: discussion and replies # -------------------------------------------------- # Do: even with a wrong destination, a reply should end up in the correct thread - frog_groups = format_and_process(MAIL_TEMPLATE, email_from='other@gmail.com', + frog_groups = format_and_process(MAIL_TEMPLATE, email_from='other4@gmail.com', msg_id='<1198923581.41972151344608186760.JavaMail.diff1@agrolait.com>', to='erroneous@example.com>', subject='Re: news', extra='In-Reply-To: <12321321-openerp-%d-mail.group@example.com>\n' % frog_group.id) @@ -458,14 +472,14 @@ class TestMailgateway(TestMailBase): 'message_process: reply on Frogs should not have created a duplicate group with old subject') frog_group = self.mail_group.browse(cr, uid, frog_groups[0]) # Test: one new message - self.assertEqual(len(frog_group.message_ids), 2, 'message_process: group should contain 2 messages after reply') + self.assertEqual(len(frog_group.message_ids), 3, 'message_process: group should contain 2 messages after reply') # Test: author (and not recipient) added as follower frog_follower_ids = set([p.id for p in frog_group.message_follower_ids]) self.assertEqual(frog_follower_ids, set([p1id, p2id]), 'message_process: after reply, group should have 2 followers') # Do: due to some issue, same email goes back into the mailgateway - frog_groups = format_and_process(MAIL_TEMPLATE, email_from='other@gmail.com', + frog_groups = format_and_process(MAIL_TEMPLATE, email_from='other4@gmail.com', msg_id='<1198923581.41972151344608186760.JavaMail.diff1@agrolait.com>', subject='Re: news', extra='In-Reply-To: <12321321-openerp-%d-mail.group@example.com>\n' % frog_group.id) # Test: no group 'Re: news' created, still only 1 Frogs group @@ -476,20 +490,18 @@ class TestMailgateway(TestMailBase): 'message_process: reply on Frogs should not have created a duplicate group with old subject') frog_group = self.mail_group.browse(cr, uid, frog_groups[0]) # Test: no new message - self.assertEqual(len(frog_group.message_ids), 2, 'message_process: message with already existing message_id should not have been duplicated') + self.assertEqual(len(frog_group.message_ids), 3, 'message_process: message with already existing message_id should not have been duplicated') # Test: message_id is still unique msg_ids = self.mail_message.search(cr, uid, [('message_id', 'ilike', '<1198923581.41972151344608186760.JavaMail.diff1@agrolait.com>')]) self.assertEqual(len(msg_ids), 1, 'message_process: message with already existing message_id should not have been duplicated') # -------------------------------------------------- - # Test3: email_from and partner finding + # Test4: email_from and partner finding # -------------------------------------------------- # Data: extra partner with Raoul's email -> test the 'better author finding' extra_partner_id = self.res_partner.create(cr, uid, {'name': 'A-Raoul', 'email': 'test_raoul@email.com'}) - # extra_user_id = self.res_users.create(cr, uid, {'name': 'B-Raoul', 'email': self.user_raoul.email}) - # extra_user_pid = self.res_users.browse(cr, uid, extra_user_id).partner_id.id # Do: post a new message, with a known partner -> duplicate emails -> partner format_and_process(MAIL_TEMPLATE, email_from='Lombrik Lubrik <test_raoul@email.com>', @@ -534,7 +546,7 @@ class TestMailgateway(TestMailBase): self.res_users.write(cr, uid, self.user_raoul_id, {'email': raoul_email}) # -------------------------------------------------- - # Test4: misc gateway features + # Test5: misc gateway features # -------------------------------------------------- # Do: incoming email with model that does not accepts incoming emails must raise @@ -568,7 +580,7 @@ class TestMailgateway(TestMailBase): frog_group = self.mail_group.browse(cr, uid, frog_groups[0]) msg = frog_group.message_ids[0] # Test: plain text content should be wrapped and stored as html - self.assertEqual(msg.body, '<pre>\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n</pre>', + self.assertIn('<pre>\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n</pre>', msg.body, 'message_process: plaintext incoming email incorrectly parsed') @mute_logger('openerp.addons.mail.mail_thread', 'openerp.osv.orm') |
