Skip to content
Permalink
Browse files

[FIX] mail: tests: exclude domain from message_id

If the database name contains one of the tested strings, it can render
the assertion of the test invalid or inconclusive. Ensure we strip it
away during the tests.

opw: 1957055

closes #31987

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
  • Loading branch information...
Icallhimtest committed Mar 20, 2019
1 parent f1c72ee commit a95811eee255aeb63c7e00e9ff589d3f03265f40
Showing with 14 additions and 14 deletions.
  1. +4 −4 addons/mail/tests/test_mail_gateway.py
  2. +10 −10 addons/mail/tests/test_mail_message.py
@@ -739,7 +739,7 @@ def test_private_discussion(self):
self.assertEqual(msg.model, False,
'message_post: private discussion: context key "thread_model" not correctly ignored when having no res_id')
# Test: message-id
self.assertIn('openerp-private', msg.message_id, 'message_post: private discussion: message-id should contain the private keyword')
self.assertIn('openerp-private', msg.message_id.split('@')[0], 'message_post: private discussion: message-id should contain the private keyword')

# Do: Bert replies through mailgateway (is a customer)
self.format_and_process(
@@ -767,9 +767,9 @@ def test_private_discussion(self):
@mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models', 'odoo.addons.mail.models.mail_mail')
def test_forward_parent_id(self):
msg = self.group_pigs.sudo(self.user_employee).message_post(no_auto_thread=True, subtype='mail.mt_comment')
self.assertNotIn(msg.model, msg.message_id)
self.assertNotIn('-%d-' % msg.res_id, msg.message_id)
self.assertIn('reply_to', msg.message_id)
self.assertNotIn(msg.model, msg.message_id.split('@')[0])
self.assertNotIn('-%d-' % msg.res_id, msg.message_id.split('@')[0])
self.assertIn('reply_to', msg.message_id.split('@')[0])

# forward it to a new thread AND an existing thread
fw_msg_id = '<THIS.IS.A.FW.MESSAGE.1@bert.fr>'
@@ -32,15 +32,15 @@ def test_mail_message_values_basic(self):
'reply_to': 'test.reply@example.com',
'email_from': 'test.from@example.com',
})
self.assertIn('-private', msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
self.assertIn('-private', msg.message_id.split('@')[0], 'mail_message: message_id for a void message should be a "private" one')
self.assertEqual(msg.reply_to, 'test.reply@example.com')
self.assertEqual(msg.email_from, 'test.from@example.com')

def test_mail_message_values_default(self):
self.env['ir.config_parameter'].search([('key', '=', 'mail.catchall.domain')]).unlink()

msg = self.env['mail.message'].sudo(self.user_employee).create({})
self.assertIn('-private', msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
self.assertIn('-private', msg.message_id.split('@')[0], 'mail_message: message_id for a void message should be a "private" one')
self.assertEqual(msg.reply_to, '%s <%s>' % (self.user_employee.name, self.user_employee.email))
self.assertEqual(msg.email_from, '%s <%s>' % (self.user_employee.name, self.user_employee.email))

@@ -50,7 +50,7 @@ def test_mail_message_values_alias(self):
self.env['ir.config_parameter'].search([('key', '=', 'mail.catchall.alias')]).unlink()

msg = self.env['mail.message'].sudo(self.user_employee).create({})
self.assertIn('-private', msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
self.assertIn('-private', msg.message_id.split('@')[0], 'mail_message: message_id for a void message should be a "private" one')
self.assertEqual(msg.reply_to, '%s <%s>' % (self.user_employee.name, self.user_employee.email))
self.assertEqual(msg.email_from, '%s <%s>' % (self.user_employee.name, self.user_employee.email))

@@ -61,7 +61,7 @@ def test_mail_message_values_alias_catchall(self):
self.env['ir.config_parameter'].set_param('mail.catchall.alias', alias_catchall)

msg = self.env['mail.message'].sudo(self.user_employee).create({})
self.assertIn('-private', msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
self.assertIn('-private', msg.message_id.split('@')[0], 'mail_message: message_id for a void message should be a "private" one')
self.assertEqual(msg.reply_to, '%s <%s@%s>' % (self.env.user.company_id.name, alias_catchall, alias_domain))
self.assertEqual(msg.email_from, '%s <%s>' % (self.user_employee.name, self.user_employee.email))

@@ -72,7 +72,7 @@ def test_mail_message_values_document_no_alias(self):
'model': 'mail.channel',
'res_id': self.group_pigs.id
})
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id.split('@')[0], 'mail_message: message_id for a void message should be a "private" one')
self.assertEqual(msg.reply_to, '%s <%s>' % (self.user_employee.name, self.user_employee.email))
self.assertEqual(msg.email_from, '%s <%s>' % (self.user_employee.name, self.user_employee.email))

@@ -85,7 +85,7 @@ def test_mail_message_values_document_alias(self):
'model': 'mail.channel',
'res_id': self.group_pigs.id
})
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id.split('@')[0], 'mail_message: message_id for a void message should be a "private" one')
self.assertEqual(msg.reply_to, '%s %s <%s@%s>' % (self.env.user.company_id.name, self.group_pigs.name, self.group_pigs.alias_name, alias_domain))
self.assertEqual(msg.email_from, '%s <%s>' % (self.user_employee.name, self.user_employee.email))

@@ -99,7 +99,7 @@ def test_mail_message_values_document_alias_catchall(self):
'model': 'mail.channel',
'res_id': self.group_pigs.id
})
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id.split('@')[0], 'mail_message: message_id for a void message should be a "private" one')
self.assertEqual(msg.reply_to, '%s %s <%s@%s>' % (self.env.user.company_id.name, self.group_pigs.name, self.group_pigs.alias_name, alias_domain))
self.assertEqual(msg.email_from, '%s <%s>' % (self.user_employee.name, self.user_employee.email))

@@ -109,9 +109,9 @@ def test_mail_message_values_no_auto_thread(self):
'res_id': self.group_pigs.id,
'no_auto_thread': True,
})
self.assertIn('reply_to', msg.message_id)
self.assertNotIn('mail.channel', msg.message_id)
self.assertNotIn('-%d-' % self.group_pigs.id, msg.message_id)
self.assertIn('reply_to', msg.message_id.split('@')[0])
self.assertNotIn('mail.channel', msg.message_id.split('@')[0])
self.assertNotIn('-%d-' % self.group_pigs.id, msg.message_id.split('@')[0])

def test_mail_message_notify_from_mail_mail(self):
# Due ot post-commit hooks, store send emails in every step

0 comments on commit a95811e

Please sign in to comment.
You can’t perform that action at this time.