Commit 02a409c3 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: test test

parent 31eb1b80
......@@ -24,6 +24,8 @@
import transaction
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin,SlapOSTestCaseMixinWithAbort, TemporaryAlarmScript, PinnedDateTime
from Products.ERP5Type.tests.utils import FileUpload
import os
from DateTime import DateTime
from App.Common import rfc1123_date
......@@ -458,6 +460,33 @@ class TestTicket_createProjectEvent(TestCRMSkinsMixin):
),
)
def makeImageFileUpload(self):
import Products.ERP5.tests
file_upload = FileUpload(
os.path.join(os.path.dirname(Products.ERP5.tests.__file__),
'test_data', 'images', 'erp5_logo.png'))
file_upload.headers['Content-Type'] = 'image/png'
return file_upload
def assertSameEventAttachmentList(self, event, information_dict_list=None):
if information_dict_list is None:
information_dict_list = []
event_information_dict_list = []
for information in event.getAttachmentInformationList():
if information['uid'] != information['filename']:
event_information_dict_list.append({
'title': information['filename'],
'content_type': information['content_type'],
'index': information['index']
})
import json
self.assertSameSet(
[json.dumps(x) for x in event_information_dict_list],
[json.dumps(x) for x in information_dict_list]
)
def test_Ticket_createProjectEvent_REQUEST_disallowed(self):
ticket = self.createUsualTicket()
self.assertRaises(
......@@ -467,7 +496,7 @@ class TestTicket_createProjectEvent(TestCRMSkinsMixin):
'foo resource', 'foo text',
REQUEST={})
def test_Ticket_createProjectEvent_incoming_event(self):
def test_Ticket_createProjectEvent_incomingEventWithoutAttachment(self):
ticket = self.createUsualTicket()
event = ticket.Ticket_createProjectEvent(
'foo_title', 'incoming', 'Letter',
......@@ -485,10 +514,36 @@ class TestTicket_createProjectEvent(TestCRMSkinsMixin):
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.assertSameEventAttachmentList(event)
self.assertEquals(event.getSimulationState(), 'stopped')
def test_Ticket_createProjectEvent_incomingEventWithAttachment(self):
ticket = self.createUsualTicket()
event = ticket.Ticket_createProjectEvent(
'foo_title', 'incoming', 'Web Message',
'foo resource', 'foo text',
attachment=self.makeImageFileUpload()
)
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.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.assertSameEventAttachmentList(event, [{
"index": 2,
"content_type": "image/png",
"title": "erp5_logo.png"
}])
self.assertEquals(event.getSimulationState(), 'stopped')
def test_Ticket_createProjectEvent_outgoing_event(self):
def test_Ticket_createProjectEvent_outgoingEvent(self):
ticket = self.createUsualTicket()
event = ticket.Ticket_createProjectEvent(
'foo_title', 'outgoing', 'Web Message',
......@@ -506,6 +561,6 @@ class TestTicket_createProjectEvent(TestCRMSkinsMixin):
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.assertSameEventAttachmentList(event)
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