Commit 7a31d3fa authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_crm: Migrate Unit Tests.

parent 8e9bd755
......@@ -43,8 +43,11 @@ from email.mime.text import MIMEText
from email import encoders, message_from_string
from DateTime import DateTime
import Products.ERP5.tests
def makeFilePath(name):
return os.path.join(os.path.dirname(__file__), 'test_data', 'crm_emails', name)
return os.path.join(os.path.dirname(Products.ERP5.tests.__file__),
'test_data', 'crm_emails', name)
def makeFileUpload(name):
path = makeFilePath(name)
......@@ -108,7 +111,6 @@ class TestCRM(BaseTestCRM):
def test_Event_CreateRelatedEvent(self):
# test workflow to create a related event from responded event
event_module = self.portal.event_module
portal_workflow = self.portal.portal_workflow
ticket = self.portal.campaign_module.newContent(portal_type='Campaign',)
for ptype in [x for x in self.portal.getPortalEventTypeList() if x !=
'Acknowledgement']:
......@@ -152,7 +154,6 @@ class TestCRM(BaseTestCRM):
def test_Ticket_CreateRelatedEvent(self):
# test action to create a related event from a ticket
event_module_url = self.portal.event_module.absolute_url()
ticket = self.portal.meeting_module.newContent(portal_type='Meeting')
for ptype in [x for x in self.portal.getPortalEventTypeList() if x !=
'Acknowledgement']:
......@@ -416,7 +417,6 @@ class TestCRM(BaseTestCRM):
"""
portal_type = "Support Request"
title = "Title of the Support Request"
content = "This is the content of the Support Request"
module = self.portal.support_request_module
support_request = module.newContent(portal_type=portal_type,
title=title,)
......@@ -550,7 +550,7 @@ class TestCRM(BaseTestCRM):
self.assertEqual(event_list, [])
event_list = campaign.getFollowUpRelatedValueList(portal_type='Mail Message')
self.assertNotEquals(event_list, [])
destination_list = map(lambda x: x.getDestinationValue(), event_list)
destination_list = [x.getDestinationValue() for x in event_list]
self.assertEqual(destination_list, [first_user])
mail_message = event_list[0]
self.assertEqual(sender.getRelativeUrl(), mail_message.getSource())
......@@ -571,10 +571,10 @@ class TestCRM(BaseTestCRM):
self.assertEqual([], event_list)
event_list = campaign.getFollowUpRelatedValueList(portal_type='Visit')
self.assertNotEquals([], event_list)
destination_uid_list = map(lambda x: x.getDestinationUid(), event_list)
destination_uid_list = [x.getDestinationUid() for x in event_list]
self.assertEqual([organisation.getUid()], destination_uid_list)
resource_value_list = map(lambda x: x.getResourceValue(), event_list)
resource_value_list = [x.getResourceValue() for x in event_list]
self.assertEqual([service], resource_value_list)
def test_OutcomePath(self):
......@@ -648,8 +648,7 @@ class TestCRMMailIngestion(BaseTestCRM):
def _readTestData(self, filename):
"""read test data from data directory."""
return file(os.path.join(os.path.dirname(__file__),
'test_data', 'crm_emails', filename)).read()
return file(makeFilePath(filename)).read()
def _ingestMail(self, filename=None, data=None):
"""ingest an email from the mail in data dir named `filename`"""
......@@ -685,8 +684,6 @@ class TestCRMMailIngestion(BaseTestCRM):
('"He<" <he@erp5.org>', ['person_module/he']),
)
portal = self.portal
Base_getEntityListFromFromHeader = portal.Base_getEntityListFromFromHeader
pc = self.portal.portal_catalog
for header, expected_paths in expected_values:
paths = [entity.getRelativeUrl()
for entity in portal.Base_getEntityListFromFromHeader(header)]
......@@ -771,7 +768,7 @@ class TestCRMMailIngestion(BaseTestCRM):
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(
self.portal.person_module.newContent(
portal_type='Person',
default_email_coordinate_text='destination@example.com',)
organisation = self.portal.organisation_module.newContent(
......@@ -970,10 +967,10 @@ class TestCRMMailIngestion(BaseTestCRM):
portal_type = 'Mail Message'
event = self.portal.getDefaultModule(portal_type).newContent(portal_type=portal_type)
# build message content with flwd attachment
plain_text_message = 'You can read this'
html_filename = 'broken_html.html'
file_path = '%s/test_data/%s' % (__file__.rstrip('c').replace(__name__+'.py', ''),
html_filename,)
file_path = '%s/test_data/%s' % (
os.path.dirname(Products.ERP5.tests.__file__),
html_filename)
html_message = open(file_path, 'r').read()
message = MIMEMultipart('alternative')
message.attach(MIMEText('text plain content', _charset='utf-8'))
......@@ -1998,7 +1995,7 @@ class TestCRMMailSend(BaseTestCRM):
mail_message.send(extra_header_dict={"X-test-header": "test"})
self.tic()
(from_url, to_url, last_message,), = self.portal.MailHost._message_list
(_, _, last_message,), = self.portal.MailHost._message_list
message = message_from_string(last_message)
self.assertEqual("test", message.get("X-test-header"))
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testCRM</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testCRM</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testCRM</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testCrmReports</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testCrmReports</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testCrmReports</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testCRM
test.erp5.testCRMNotificationTool
test.erp5.testCRMSupportRequest
test.erp5.testCrmReports
test.erp5.testERP5WebWithCRM
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_test
erp5_web
\ No newline at end of file
erp5_web
erp5_core_proxy_field_legacy
erp5_pdm
erp5_dms
\ No newline at end of file
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