Commit 6d37ca31 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: WIP: content type parameter seems useless

parent 595fee10
......@@ -3,6 +3,10 @@ It creates new Event for any context which become follow_up of created Event.
"""
from erp5.component.tool.NotificationTool import buildEmailMessage
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
ticket = context
REQUEST = context.REQUEST
......@@ -62,7 +66,6 @@ event_kw = {
'follow_up_value': ticket,
'language': language,
'data': email.as_string(),
'content_type': content_type,
}
# Create event
module = portal.getDefaultModule(portal_type=portal_type)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, direction, portal_type, resource, text_content, content_type, attachment=None, notification_message=None, substitution_method_parameter_dict=None, keep_draft=False, source=None, destination=None, language=None, comment=None, **kw</string> </value>
<value> <string>title, direction, portal_type, resource, text_content, attachment=None, notification_message=None, substitution_method_parameter_dict=None, keep_draft=False, source=None, destination=None, language=None, comment=None, REQUEST=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -27,6 +27,7 @@ from erp5.component.test.SlapOSTestCaseMixin import \
from DateTime import DateTime
from App.Common import rfc1123_date
from zExceptions import Unauthorized
def getFakeSlapState():
......@@ -423,3 +424,88 @@ class TestSlapOSFolder_getTicketFeedUrl(TestCRMSkinsMixin):
def test_Folder_getTicketFeedUrl_incident_response_module(self):
self._test(self.portal.incident_response_module)
class TestTicket_createProjectEvent(TestCRMSkinsMixin):
def createUsualTicket(self):
portal = self.portal
return portal.support_request_module.newContent(
portal_type='Support Request',
title='test support request',
source_value=portal.person_module.newContent(
portal_type='Person',
title='ticket source person'
),
source_section_value=portal.organisation_module.newContent(
portal_type='Organisation',
title='ticket source section organisation'
),
source_project_value=portal.project_module.newContent(
portal_type='Project',
title='ticket source project'
),
destination_value=portal.person_module.newContent(
portal_type='Person',
title='ticket destination person'
),
destination_section_value=portal.organisation_module.newContent(
portal_type='Organisation',
title='ticket destination section organisation'
),
destination_project_value=portal.project_module.newContent(
portal_type='Project',
title='ticket destination project'
),
)
def test_Ticket_createProjectEvent_REQUEST_disallowed(self):
ticket = self.createUsualTicket()
self.assertRaises(
Unauthorized,
ticket.Ticket_createProjectEvent,
'foo_title', 'foo_direction', 'foo portal type',
'foo resource', 'foo text',
REQUEST={})
def test_Ticket_createProjectEvent_incoming_event(self):
ticket = self.createUsualTicket()
event = ticket.Ticket_createProjectEvent(
'foo_title', 'incoming', 'Letter',
'foo resource', 'foo text',
)
self.assertEquals(event.getPortalType(), 'Letter')
self.assertEquals(event.getTitle(), 'foo_title')
self.assertEquals(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEquals(event.getResource(), 'foo resource')
self.assertEquals(event.getSource(), ticket.getDestination())
self.assertEquals(event.getSourceSection(), ticket.getDestinationSection())
self.assertEquals(event.getSourceProject(), ticket.getDestinationProject())
self.assertEquals(event.getDestination(), ticket.getSource())
self.assertEquals(event.getDestinationSection(), ticket.getSourceSection())
self.assertEquals(event.getDestinationProject(), ticket.getSourceProject())
self.assertEquals(event.getTextContent(), 'foo text')
self.assertEquals(event.getContentType(), 'text/plain')
self.assertSameSet([x for x in event.getAttachmentInformationList() if x['uid'] != x['filename']], [])
self.assertEquals(event.getSimulationState(), 'stopped')
def test_Ticket_createProjectEvent_outgoing_event(self):
ticket = self.createUsualTicket()
event = ticket.Ticket_createProjectEvent(
'foo_title', 'outgoing', 'Web Message',
'foo resource', 'foo text',
)
self.assertEquals(event.getPortalType(), 'Web Message')
self.assertEquals(event.getTitle(), 'foo_title')
self.assertEquals(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEquals(event.getResource(), 'foo resource')
self.assertEquals(event.getDestination(), ticket.getDestination())
self.assertEquals(event.getDestinationSection(), ticket.getDestinationSection())
self.assertEquals(event.getDestinationProject(), ticket.getDestinationProject())
self.assertEquals(event.getSource(), ticket.getSource())
self.assertEquals(event.getSourceSection(), ticket.getSourceSection())
self.assertEquals(event.getSourceProject(), ticket.getSourceProject())
self.assertEquals(event.getTextContent(), 'foo text')
self.assertEquals(event.getContentType(), 'text/plain')
self.assertSameSet([x for x in event.getAttachmentInformationList() if x['uid'] != x['filename']], [])
self.assertEquals(event.getSimulationState(), 'delivered')
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