From a3e404e17ea36447e0bbe5f92aef94e26c299366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 25 Jan 2023 12:12:55 +0000 Subject: [PATCH] [IMP] mail: improve test tooling Add some information and values propagation in some custom asserts in mail test tooling. Task-2088884 (Mail: Use editable computed stored fields in composer) Part-of: odoo/odoo#110919 --- addons/mail/tests/common.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mail/tests/common.py b/addons/mail/tests/common.py index e9a4ae5ec1f..eaa5d21bb26 100644 --- a/addons/mail/tests/common.py +++ b/addons/mail/tests/common.py @@ -567,7 +567,11 @@ class MockEmail(common.BaseCase, MockSmtplibCase): if 'attachments_info' in expected: attachments = sent_mail['attachments'] for attachment_info in expected['attachments_info']: - attachment = next(attach for attach in attachments if attach[0] == attachment_info['name']) + attachment = next((attach for attach in attachments if attach[0] == attachment_info['name']), False) + self.assertTrue( + bool(attachment), + f'Attachment {attachment_info["name"]} not found in attachments', + ) if attachment_info.get('raw'): self.assertEqual(attachment[1], attachment_info['raw']) if attachment_info.get('type'): @@ -907,9 +911,10 @@ class MailCase(MockEmail): if not self.mail_unlink_sent: self.assertMailMail( partners, mail_status, - author=message.author_id if message.author_id else message.email_from, + author=message_info.get('fields_values', {}).get('author_id') or message.author_id or message.email_from, mail_message=message, email_values=email_values, + fields_values=message_info.get('fields_values'), ) else: for recipient in partners: