diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-06-06 13:33:16 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-06-06 13:33:16 +0200 |
| commit | 4f18c7c44bbe3d1b6adacd0ee5bd2e18a9316b38 (patch) | |
| tree | 036a1fefca9068fa3b85b979b81f697f98e33699 /addons/test_mail | |
| parent | 71a50a2214748fec413c5a0f042d0e7172ae6ea9 (diff) | |
[FIX] test_mail: correct test
*/ Adapt test to new version
*/ do not use removed method `do_in_onchange`
*/ remove duplicated test
Diffstat (limited to 'addons/test_mail')
| -rw-r--r-- | addons/test_mail/tests/test_mail_template.py | 58 |
1 files changed, 8 insertions, 50 deletions
diff --git a/addons/test_mail/tests/test_mail_template.py b/addons/test_mail/tests/test_mail_template.py index 3a70a575011..3d1b18e68a1 100644 --- a/addons/test_mail/tests/test_mail_template.py +++ b/addons/test_mail/tests/test_mail_template.py @@ -89,16 +89,15 @@ class TestMailTemplate(BaseFunctionalTest, MockEmails, TestRecipients): attachments_onchange = [composer.attachment_ids] # template_1 has two static attachments and one dynamically generated report, # template_2 only has the report, so we should get 3, 1, 3 attachments - attachment_numbers = [0, 3, 1, 3, 0] + attachment_numbers = [0, 3, 1, 3, 3] - with self.env.do_in_onchange(): - for template in onchange_templates: - onchange = composer.onchange_template_id( - template.id if template else False, 'comment', self.test_record._name, self.test_record.id - ) - values = composer._convert_to_record(composer._convert_to_cache(onchange['value'])) - attachments_onchange.append(values['attachment_ids']) - composer.update(onchange['value']) + for template in onchange_templates: + onchange = composer.onchange_template_id( + template.id if template else False, 'comment', self.test_record._name, self.test_record.id + ) + values = composer._convert_to_record(composer._convert_to_cache(onchange['value'])) + attachments_onchange.append(values['attachment_ids']) + composer.update(onchange['value']) self.assertEqual( [len(attachments) for attachments in attachments_onchange], @@ -275,44 +274,3 @@ class TestMailTemplate(BaseFunctionalTest, MockEmails, TestRecipients): new_partner = Partner.search([('email', '=', email_new_partner)]) self.assertTrue(new_partner) self.assertEqual(new_partner.company_id, company1) - - def test_composer_template_onchange_attachments(self): - """Tests that all attachments are added to the composer, - static attachments are not duplicated and while reports are re-generated, - and that intermediary attachments are dropped.""" - - composer = self.env['mail.compose.message'].with_context(default_attachment_ids=[]).create({}) - report_template = self.env.ref('web.action_report_externalpreview') - template_1 = self.email_template.copy({ - 'report_template': report_template.id, - }) - template_2 = self.email_template.copy({ - 'attachment_ids': False, - 'report_template': report_template.id, - }) - - onchange_templates = [template_1, template_2, template_1, False] - attachments_onchange = [composer.attachment_ids] - # template_1 has two static attachments and one dynamically generated report, - # template_2 only has the report, so we should get 3, 1, 3 attachments - # and when there is no template, no attachments - attachment_numbers = [0, 3, 1, 3, 0] - - with self.env.do_in_onchange(): - for template in onchange_templates: - onchange = composer.onchange_template_id( - template.id if template else False, 'comment', 'mail.test.simple', self.test_record.id - ) - values = composer._convert_to_record(composer._convert_to_cache(onchange['value'])) - attachments_onchange.append(values['attachment_ids']) - composer.update(onchange['value']) - - self.assertEqual( - [len(attachments) for attachments in attachments_onchange], - attachment_numbers, - ) - - self.assertTrue( - len(attachments_onchange[1] & attachments_onchange[3]) == 2, - "The two static attachments on the template should be common to the two onchanges" - ) |
