Commit 8b7f9520 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_interface_post: first commit of test_exportAllExportableLetterPostInAPDFDocument

parent cf3c14b6
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
import email import email
import time import time
from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import createZODBPythonScript, removeZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript, removeZODBPythonScript
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from DateTime import DateTime from DateTime import DateTime
class TestInterfacePost(ERP5TypeLiveTestCase): class TestInterfacePost(ERP5TypeTestCase):
""" """
Tests the creation of "Post" documents when their related event type Tests the creation of "Post" documents when their related event type
is sent. is sent.
...@@ -51,12 +51,11 @@ class TestInterfacePost(ERP5TypeLiveTestCase): ...@@ -51,12 +51,11 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
""" """
self.portal.MailHost.reset() self.portal.MailHost.reset()
createZODBPythonScript( self.user = self.createSimpleUser('user', 'user', 'admin')
self.portal.portal_skins.custom, if self.user is not None and 'default_email' not in self.user:
"LetterPost_export", self.user.edit(
"", default_email_coordinate_text='user@nexedi.com'
"if context.getSimulationState() == 'exportable':\n context.export()", )
)
# Make sure to have a difference of at least 1 second between test_launch_date # Make sure to have a difference of at least 1 second between test_launch_date
# and creation_date of new documents, otherwise they won't be found by catalog # and creation_date of new documents, otherwise they won't be found by catalog
...@@ -100,9 +99,17 @@ class TestInterfacePost(ERP5TypeLiveTestCase): ...@@ -100,9 +99,17 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
else: else:
return result_list return result_list
def stepCreateMailMessage(self, sequence=None, sequence_list=None): def stepAllowAutoExportOfLetters(self, sequence=None, sequence_list=None):
createZODBPythonScript(
self.portal.portal_skins.custom,
"LetterPost_export",
"",
"if context.getSimulationState() == 'exportable':\n context.export()",
)
def _stepCreateEvent(self, portal_type, sequence=None, sequence_list=None):
mail_message = self.portal.event_module.newContent( mail_message = self.portal.event_module.newContent(
portal_type='Mail Message', portal_type=portal_type,
source_value=self.sender, source_value=self.sender,
destination_value_list=self.recipient_list, destination_value_list=self.recipient_list,
title='Promotional campaign', title='Promotional campaign',
...@@ -111,6 +118,16 @@ class TestInterfacePost(ERP5TypeLiveTestCase): ...@@ -111,6 +118,16 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
sequence['mail_message'] = mail_message sequence['mail_message'] = mail_message
sequence.setdefault('mail_message_list', []).append(mail_message) sequence.setdefault('mail_message_list', []).append(mail_message)
def stepCreateMailMessage(self, sequence=None, sequence_list=None):
self._stepCreateEvent(portal_type='Mail Message',
sequence=sequence,
sequence_list=sequence_list)
def stepCreateLetter(self, sequence=None, sequence_list=None):
self._stepCreateEvent(portal_type='Letter',
sequence=sequence,
sequence_list=sequence_list)
def stepCreateInternetMessagePost(self, sequence=None, sequence_list=None): def stepCreateInternetMessagePost(self, sequence=None, sequence_list=None):
internet_message_post = self.portal.internet_message_post_module.newContent( internet_message_post = self.portal.internet_message_post_module.newContent(
portal_type='Internet Message Post', portal_type='Internet Message Post',
...@@ -287,6 +304,12 @@ class TestInterfacePost(ERP5TypeLiveTestCase): ...@@ -287,6 +304,12 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
self.assertEqual(response.getDestinationTitle(), 'sender') self.assertEqual(response.getDestinationTitle(), 'sender')
self.assertEqual(response.getSimulationState(), 'delivered') self.assertEqual(response.getSimulationState(), 'delivered')
def stepLaunchExportOnLetterPostModule(self, sequence=None, sequence_list=None):
self.assertIn(
"Report%20Started",
self.portal.letter_post_module.LetterPostModule_exportExportableLetterPost()
)
def test_emailSendingIsPilotedByInternetMessagePost(self): def test_emailSendingIsPilotedByInternetMessagePost(self):
""" """
""" """
...@@ -361,3 +384,31 @@ class TestInterfacePost(ERP5TypeLiveTestCase): ...@@ -361,3 +384,31 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
""" """
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepLoginAsUser(self, sequence=None):
self.loginByUserName('user')
def stepLogin(self, sequence=None):
self.loginByUserName()
def stepCheckAggregatingPDFDocument(self, sequence=None, sequence_list=None):
pdf_document_list = self._portal_catalog(portal_type='PDF')
self.assertEqual(len(pdf_document_list), 1)
def test_exportAllExportableLetterPostInAPDFDocument(self):
"""
Test the action on Letter Post Module to export all exportable Letter Posts
and aggregate their content in a unique PDF document (easy to print)
"""
sequence_list = SequenceList()
sequence_string = """
stepCreateLetter
stepCreateLetter
stepLoginAsUser
stepLaunchExportOnLetterPostModule
stepLogin
stepTic
stepCheckOnlyOneMessageHasBeenSentFromMailHost
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
\ 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