[Erp5-report] r22305 - in /erp5/trunk/products/ERP5: Document/ tests/ tests/test_data/crm_e...

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jul 7 10:59:07 CEST 2008


Author: jerome
Date: Mon Jul  7 10:59:05 2008
New Revision: 22305

URL: http://svn.erp5.org?rev=22305&view=rev
Log:
fix a problem in converting subject from emails with encoded subject.
Also add missing test for encoded emails

Added:
    erp5/trunk/products/ERP5/tests/test_data/crm_emails/encoded
Modified:
    erp5/trunk/products/ERP5/Document/EmailDocument.py
    erp5/trunk/products/ERP5/tests/testCRM.py

Modified: erp5/trunk/products/ERP5/Document/EmailDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/EmailDocument.py?rev=22305&r1=22304&r2=22305&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/EmailDocument.py (original)
+++ erp5/trunk/products/ERP5/Document/EmailDocument.py Mon Jul  7 10:59:05 2008
@@ -125,9 +125,11 @@
     for (name, value) in self._getMessage().items():
       for text, encoding in decode_header(value):
         if encoding is not None:
-          result[name] = result.get(name, '') + text.decode(encoding).encode('utf-8')
+          text = text.decode(encoding).encode('utf-8')
+        if name in result:
+          result[name] = '%s %s' % (result[name], text)
         else:
-          result[name] = result.get(name, '') + text
+          result[name] = text
     return result
 
   security.declareProtected(Permissions.AccessContentsInformation, 'getAttachmentInformationList')

Modified: erp5/trunk/products/ERP5/tests/testCRM.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testCRM.py?rev=22305&r1=22304&r2=22305&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testCRM.py (original)
+++ erp5/trunk/products/ERP5/tests/testCRM.py Mon Jul  7 10:59:05 2008
@@ -485,16 +485,27 @@
     self.assertEqual(document.getSourceValue().getTitle(), 'Sender')
     self.assertEqual(document.getDestinationValue().getTitle(), 'Me')
 
+  def test_encoding(self):
+    document = self._ingestMail(filename='encoded')
+
+    get_transaction().commit()
+    self.tic()
+
+    self.assertEqual(document.getContentInformation().get('To'),
+                     'Me <me at erp5.org>')
+    self.assertEqual(document.getSourceValue().getTitle(), 'Sender')
+    self.assertEqual(document.getDestinationValue().getTitle(), 'Me')
+    self.assertEqual(document.getContentInformation().get('Subject'),
+                     'Test éncödèd email')
+    self.assertEqual(document.getTitle(), 'Test éncödèd email')
+    self.assertEqual(document.getTextContent(), 'cöntént\n')
+
 
 ## TODO:
 ##
 ##  def test_attachements(self):
 ##    event = self._ingestMail('with_attachements')
 ##
-##  def test_encoding(self):
-##    event = self._ingestMail('utf8')
-##
-
 
 class TestCRMMailSend(ERP5TypeTestCase):
   """Test Mail Sending for CRM

Added: erp5/trunk/products/ERP5/tests/test_data/crm_emails/encoded
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/test_data/crm_emails/encoded?rev=22305&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/tests/test_data/crm_emails/encoded (added)
+++ erp5/trunk/products/ERP5/tests/test_data/crm_emails/encoded Mon Jul  7 10:59:05 2008
@@ -1,0 +1,10 @@
+Date: Mon, 7 Jul 2008 10:17:56 +0200
+From: Sender <sender at customer.com>
+To: Me <me at erp5.org>
+Subject: Test =?utf8?B?w6luY8O2ZMOoZA==?= email
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf8
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+
+c=C3=B6nt=C3=A9nt




More information about the Erp5-report mailing list