From 867d4fd16f345805999f19ae49b6f11829c27ced Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Tue, 1 Apr 2008 14:47:40 +0000 Subject: [PATCH] Remove wrong argument. Add a forwarded mail test. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20251 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/testCRM.py | 36 +++++++++++++------ .../ERP5/tests/test_data/crm_emails/forwarded | 23 ++++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 product/ERP5/tests/test_data/crm_emails/forwarded diff --git a/product/ERP5/tests/testCRM.py b/product/ERP5/tests/testCRM.py index 303a24bceb..207ad61079 100644 --- a/product/ERP5/tests/testCRM.py +++ b/product/ERP5/tests/testCRM.py @@ -348,42 +348,42 @@ class TestCRMMailIngestion(ERP5TypeTestCase): message = email.message_from_string(self._readTestData('simple')) message.replace_header('subject', 'Visit:Company A') data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Visit') self.assertEqual(document.getTitle(), 'Company A') message = email.message_from_string(self._readTestData('simple')) message.replace_header('subject', 'Fax:Company B') data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Fax Message') self.assertEqual(document.getTitle(), 'Company B') message = email.message_from_string(self._readTestData('simple')) message.replace_header('subject', 'TEST:Company B') data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Mail Message') self.assertEqual(document.getTitle(), 'TEST:Company B') message = email.message_from_string(self._readTestData('simple')) message.replace_header('subject', 'visit:Company A') data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Visit') self.assertEqual(document.getTitle(), 'Company A') message = email.message_from_string(self._readTestData('simple')) message.replace_header('subject', 'phone:Company B') data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Phone Call') self.assertEqual(document.getTitle(), 'Company B') message = email.message_from_string(self._readTestData('simple')) message.replace_header('subject', 'LETTER:Company C') data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Letter') self.assertEqual(document.getTitle(), 'Company C') @@ -391,7 +391,7 @@ class TestCRMMailIngestion(ERP5TypeTestCase): body = message.get_payload() message.set_payload('Visit:%s' % body) data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Visit') self.assertEqual(document.getTextContent(), body) @@ -399,14 +399,28 @@ class TestCRMMailIngestion(ERP5TypeTestCase): body = message.get_payload() message.set_payload('PHONE CALL:%s' % body) data = message.as_string() - document = self._ingestMail(self, data=data) + document = self._ingestMail(data=data) self.assertEqual(document.portal_type, 'Phone Call') self.assertEqual(document.getTextContent(), body) + def test_forwarder_mail(self): + """ + Make sure that if ingested email is forwarded one, the sender of + original mail should be the sender of event and the sender of + forwarded mail should be the recipient of event. + """ + document = self._ingestMail(filename='forwarded') + + get_transaction().commit() + self.tic() + + self.assertEqual(document.getContentInformation().get('From'), 'Me <me@erp5.org>') + self.assertEqual(document.getContentInformation().get('To'), 'crm@erp5.org') + self.assertEqual(document.getSourceValue().getTitle(), 'Sender') + self.assertEqual(document.getDestinationValue().getTitle(), 'Me') + + ## TODO: -## def test_forwarder_mail(self): -## # if there is a forwarded email, import the forwarded email -## event = self._ingestMail('forwarded') ## ## def test_attachements(self): ## event = self._ingestMail('with_attachements') diff --git a/product/ERP5/tests/test_data/crm_emails/forwarded b/product/ERP5/tests/test_data/crm_emails/forwarded new file mode 100644 index 0000000000..7b990ba190 --- /dev/null +++ b/product/ERP5/tests/test_data/crm_emails/forwarded @@ -0,0 +1,23 @@ +Return-Path: <me@erp5.org> +X-Original-To: me@erp5.org +Delivered-To: me@erp5.org +Message-ID: <4719FE4D.2070403@erp5.org> +Date: Sat, 20 Oct 2007 16:10:37 +0200 +From: Me <me@erp5.org> +User-Agent: Thunderbird 2.0.0.6 (X11/20070728) +To: crm@erp5.org +Subject: Fw:Simple Mail Test +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit + +Hello, + +Begin forwarded message: + +Subject: Simple Mail Test +Date: Sat, 20 Oct 2007 15:10:37 +0200 +From: Sender <sender@customer.com> +To: Me <me@erp5.org> + +Hello, +Content of the mail. -- 2.30.9