Commit 46c0776f authored by Nicolas Wavrant's avatar Nicolas Wavrant

fixup! erp5_interface_post: first commit of test_exportAllExportableLetterPostInAPDFDocument

parent 8b7f9520
......@@ -33,6 +33,7 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript, removeZODBPyth
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from DateTime import DateTime
class TestInterfacePost(ERP5TypeTestCase):
"""
Tests the creation of "Post" documents when their related event type
......@@ -51,8 +52,14 @@ class TestInterfacePost(ERP5TypeTestCase):
"""
self.portal.MailHost.reset()
self.user = self.createSimpleUser('user', 'user', 'admin')
if self.user is not None and 'default_email' not in self.user:
try:
self.user = self.portal.person_module['user']
except KeyError:
self.user = self.createSimpleUser('user', 'user', 'admin')
self.user.setId('user')
self.user.validate()
if 'default_email' not in self.user:
self.user.edit(
default_email_coordinate_text='user@nexedi.com'
)
......@@ -76,10 +83,11 @@ class TestInterfacePost(ERP5TypeTestCase):
self.recipient_list = [self.recipient,]
def beforeTearDown(self):
removeZODBPythonScript(
self.portal.portal_skins.custom,
"LetterPost_export"
)
if hasattr(self.portal.portal_skins.custom, "LetterPost_export"):
removeZODBPythonScript(
self.portal.portal_skins.custom,
"LetterPost_export"
)
for module_id in ('event_module', 'internet_message_post_module', 'letter_post_module'):
module = getattr(self.portal, module_id)
......@@ -108,15 +116,16 @@ class TestInterfacePost(ERP5TypeTestCase):
)
def _stepCreateEvent(self, portal_type, sequence=None, sequence_list=None):
mail_message = self.portal.event_module.newContent(
event = self.portal.event_module.newContent(
portal_type=portal_type,
source_value=self.sender,
destination_value_list=self.recipient_list,
title='Promotional campaign',
text_content=self.default_mail_text_content,
)
sequence['mail_message'] = mail_message
sequence.setdefault('mail_message_list', []).append(mail_message)
sequence['mail_message'] = event
sequence.setdefault('mail_message_list', []).append(event)
return event
def stepCreateMailMessage(self, sequence=None, sequence_list=None):
self._stepCreateEvent(portal_type='Mail Message',
......@@ -124,9 +133,14 @@ class TestInterfacePost(ERP5TypeTestCase):
sequence_list=sequence_list)
def stepCreateLetter(self, sequence=None, sequence_list=None):
self._stepCreateEvent(portal_type='Letter',
sequence=sequence,
sequence_list=sequence_list)
letter = self._stepCreateEvent(portal_type='Letter',
sequence=sequence,
sequence_list=sequence_list)
sequence.setdefault('letter_list', []).append(letter)
def stepSendAllLetter(self, sequence=None, sequence_list=None):
for letter in sequence['letter_list']:
letter.send()
def stepCreateInternetMessagePost(self, sequence=None, sequence_list=None):
internet_message_post = self.portal.internet_message_post_module.newContent(
......@@ -197,6 +211,24 @@ class TestInterfacePost(ERP5TypeTestCase):
def stepCheckOnlyOneLetterPostIsExported(self, sequence=None, sequence_list=None):
self._checkOnlyOnePostIsExportedByPortalType('Letter Post')
def stepCheckAllLetterPostAreExportable(self, sequence=None, sequence_list=None):
letter_post_list = self._portal_catalog(
portal_type='Letter Post',
simulation_state='exportable',
)
self.assertEqual(len(letter_post_list), len(sequence['letter_list']))
for letter_post in letter_post_list:
self.assertEqual(letter_post.getSimulationState(), 'exportable')
def stepCheckAllLetterPostAreExported(self, sequence=None, sequence_list=None):
letter_post_list = self._portal_catalog(
portal_type='Letter Post',
simulation_state='exported',
)
self.assertEqual(len(letter_post_list), len(sequence['letter_list']))
for letter_post in letter_post_list:
self.assertEqual(letter_post.getSimulationState(), 'exported')
def stepCheckInternetMessagePostCreated(self, sequence=None, sequence_list=None):
mail_message = sequence['mail_message']
internet_message_post_list = mail_message.getAggregateValueList(
......@@ -305,10 +337,7 @@ class TestInterfacePost(ERP5TypeTestCase):
self.assertEqual(response.getSimulationState(), 'delivered')
def stepLaunchExportOnLetterPostModule(self, sequence=None, sequence_list=None):
self.assertIn(
"Report%20Started",
self.portal.letter_post_module.LetterPostModule_exportExportableLetterPost()
)
self.portal.letter_post_module.LetterPostModule_exportExportableLetterPostActivity(user_name=self.user.getUserId())
def test_emailSendingIsPilotedByInternetMessagePost(self):
"""
......@@ -385,15 +414,11 @@ class TestInterfacePost(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string)
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)
pdf_document, = pdf_document_list
self.assertEqual(2, int(pdf_document.getContentInformation()['Pages']))
def test_exportAllExportableLetterPostInAPDFDocument(self):
"""
......@@ -404,11 +429,15 @@ class TestInterfacePost(ERP5TypeTestCase):
sequence_string = """
stepCreateLetter
stepCreateLetter
stepLoginAsUser
stepSendAllLetter
stepTic
stepCheckAllLetterPostAreExportable
stepLaunchExportOnLetterPostModule
stepLogin
stepTic
stepCheckAllLetterPostAreExported
stepTic
stepCheckOnlyOneMessageHasBeenSentFromMailHost
stepCheckAggregatingPDFDocument
"""
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