Commit 6773d615 authored by Jérome Perrin's avatar Jérome Perrin

CRM: Event.getPropertyDictFromContent should not lookup source/destination when defined on document

parent 9aabfa58
......@@ -71,8 +71,8 @@ def getEntityList(text):\n
for entity in Base_getEntityListFromFromHeader(text)]\n
\n
content_information = context.getContentInformation()\n
sender_list = getEntityList(content_information.get(\'From\', \'\'))\n
to_list = getEntityList(content_information.get(\'To\', \'\'))\n
sender_list = context.getSourceList() or getEntityList(content_information.get(\'From\', \'\'))\n
to_list = context.getDestinationList() or getEntityList(content_information.get(\'To\', \'\'))\n
cc_list = getEntityList(content_information.get(\'CC\', \'\'))\n
\n
# Build references\n
......
676
\ No newline at end of file
677
\ No newline at end of file
......@@ -28,6 +28,7 @@
import unittest
import os
import textwrap
from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.tests.utils import FileUpload
......@@ -728,6 +729,40 @@ class TestCRMMailIngestion(BaseTestCRM):
# cloned event got a new reference
self.assertNotEqual(new_event.getReference(), event.getReference())
def test_getPropertyDictFromContent_and_defined_arrow(self):
# If source/destination are set on event, then getPropertyDictFromContent
# should not lookup one based on email address.
person = self.portal.person_module.newContent(
portal_type='Person',
default_email_coordinate_text='destination@example.com',)
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation',
default_email_coordinate_text='destination@example.com',)
source_person = self.portal.person_module.newContent(
portal_type='Person',
default_email_coordinate_text='source@example.com',)
self.tic()
event = self.portal.event_module.newContent(
portal_type='Mail Message',
destination_value=organisation,
data='\r\n'.join(textwrap.dedent('''
From: Source <source@example.com>
To: destination <destination@example.com>
Subject: mail subject
content
''').splitlines()[1:]))
property_dict = event.getPropertyDictFromContent()
# destination is set on the event. In this case it is kept as is.
self.assertEquals([organisation.getRelativeUrl()],
property_dict['destination_list'])
# source is not set. In this case it is searched in catalog based on email
# address
self.assertEquals([source_person.getRelativeUrl()],
property_dict['source_list'])
def test_follow_up(self):
# follow up is found automatically, based on the content of the mail, and
# what you defined in preference regexpr.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment