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