From ec20739feef2acc57c11dfa03812468d2d0d8022 Mon Sep 17 00:00:00 2001 From: Corentin Forler <10946971+cogk@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:20:01 +0200 Subject: [PATCH] test(email): Add test for accents in subject header --- .../doctype/email_account/test_email_account.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frappe/email/doctype/email_account/test_email_account.py b/frappe/email/doctype/email_account/test_email_account.py index a1740b0b0a..b9ba3a2bc1 100644 --- a/frappe/email/doctype/email_account/test_email_account.py +++ b/frappe/email/doctype/email_account/test_email_account.py @@ -606,6 +606,20 @@ class TestInboundMail(FrappeTestCase): reference_doc = inbound_mail.reference_document() self.assertEqual(todo.name, reference_doc.name) + def test_reference_document_by_subject_match_with_accents(self): + subject = "Nouvelle tâche à faire 😃" + todo = self.new_todo(sender="test_sender@example.com", description=subject) + + mail_content = ( + self.get_test_mail(fname="incoming-subject-placeholder.raw") + .replace("{{ subject }}", f"RE: {subject}") + .encode("utf-8") + ) # note: encode to bytes because that's what triggered the error + email_account = frappe.get_doc("Email Account", "_Test Email Account 1") + inbound_mail = InboundMail(mail_content, email_account, 12345, 1) + reference_doc = inbound_mail.reference_document() + self.assertEqual(todo.name, reference_doc.name) + def test_create_communication_from_mail(self): # Create email queue record mail_content = self.get_test_mail(fname="incoming-2.raw")