Commit 839e77d5 authored by Ivan Tyagov's avatar Ivan Tyagov

Extend test to check better ingested document and add multiple timesingestion testing step.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33577 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 260a601d
...@@ -895,36 +895,56 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -895,36 +895,56 @@ class TestIngestion(ERP5TypeTestCase):
f = open(makeFilePath('email_from.txt')) f = open(makeFilePath('email_from.txt'))
document = self.receiveEmail(f.read()) document = self.receiveEmail(f.read())
self.stepTic() self.stepTic()
def stepVerifyEmailedDocuments(self, sequence=None, sequence_list=None, **kw): def stepVerifyEmailedDocumentsInitialContribution(self, sequence=None, sequence_list=None, **kw):
""" """
find the newly mailed-in document by its reference Find the newly mailed-in document and check its properties.
check its properties
""" """
# First, check document ingestion message attachment_list, ingested_document = self.verifyEmailedDocuments()
result = self.portal_catalog(portal_type='Document Ingestion Message', self.assertEquals('1', ingested_document.getRevision())
title='A Test Mail',
source_title='John Doe'
)
self.assertEqual(len(result), 1)
ingestion_message = result[0].getObject()
# Second, check attachments def stepVerifyEmailedDocumentsMultipleContribution(self, sequence=None, sequence_list=None, **kw):
attachment_list = ingestion_message.getAggregateValueList() """
self.assertEqual(len(attachment_list), 1) Find the newly mailed-in document and check its properties.
"""
# Third, check document attachment_list, ingested_document = self.verifyEmailedDocuments()
result = self.portal_catalog(portal_type='Text') self.assertTrue(ingested_document.getRevision() > '1')
self.assertEqual(len(result), 1)
document = result[0].getObject()
self.assertEqual(document.getRelativeUrl(), result[0].getRelativeUrl())
def playSequence(self, step_list, quiet): def playSequence(self, step_list, quiet):
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = ' '.join(step_list) sequence_string = ' '.join(step_list)
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def verifyEmailedDocuments(self):
"""
Basic checks for verifying newly mailed-in document
"""
# First, check document ingestion message
ingestion_message = self.portal_catalog.getResultValue(
portal_type='Document Ingestion Message',
title='A Test Mail',
source_title='John Doe')
self.assertTrue(ingestion_message is not None)
# Second, check attachments to ingested message
attachment_list = ingestion_message.getAggregateValueList()
self.assertEqual(len(attachment_list), 1)
# Third, check document is ingested properly
ingested_document = self.portal_catalog.getResultValue(
portal_type='Text',
reference='MAIL',
language='en',
version='002')
self.assertEquals('MAIL-en-002.doc', ingested_document.getSourceReference())
self.assertEquals('converted', ingested_document.getExternalProcessingState())
self.assertTrue('magic' in ingested_document.asText())
# check aggregate between 'Document Ingestion Message' and ingested document
self.assertEquals(attachment_list[0], ingested_document)
return attachment_list, ingested_document
################################## ##################################
## Tests ## Tests
################################## ##################################
...@@ -1278,7 +1298,10 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1278,7 +1298,10 @@ class TestIngestion(ERP5TypeTestCase):
,'stepCreatePerson' ,'stepCreatePerson'
# now a known sender # now a known sender
,'stepReceiveEmail' ,'stepReceiveEmail'
,'stepVerifyEmailedDocuments' ,'stepVerifyEmailedDocumentsInitialContribution'
# send one more time
,'stepReceiveEmail'
,'stepVerifyEmailedDocumentsMultipleContribution'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list, quiet)
......
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