Commit df69c4d4 authored by Nicolas Delaby's avatar Nicolas Delaby

Cleanup test

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38803 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3e003b7a
...@@ -51,16 +51,6 @@ TEST_FILES_HOME = os.path.join(os.path.dirname(__file__), 'test_document') ...@@ -51,16 +51,6 @@ TEST_FILES_HOME = os.path.join(os.path.dirname(__file__), 'test_document')
FILE_NAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})" FILE_NAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})"
REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})(-(?P<language>[a-z]{2}))?(-(?P<version>[0-9]{3}))?" REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})(-(?P<language>[a-z]{2}))?(-(?P<version>[0-9]{3}))?"
def printAndLog(msg):
"""
A utility function to print a message
to the standard output and to the LOG
at the same time
"""
msg = str(msg)
ZopeTestCase._print('\n ' + msg)
LOG('Testing... ', 0, msg)
def makeFilePath(name): def makeFilePath(name):
return os.path.join(TEST_FILES_HOME, name) return os.path.join(TEST_FILES_HOME, name)
...@@ -76,10 +66,6 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -76,10 +66,6 @@ class TestIngestion(ERP5TypeTestCase):
ERP5 Document Management System - test file ingestion mechanism ERP5 Document Management System - test file ingestion mechanism
""" """
# pseudo constants
RUN_ALL_TEST = 1
QUIET = 0
################################## ##################################
## ZopeTestCase Skeleton ## ZopeTestCase Skeleton
################################## ##################################
...@@ -98,7 +84,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -98,7 +84,7 @@ class TestIngestion(ERP5TypeTestCase):
'erp5_ingestion', 'erp5_ingestion_mysql_innodb_catalog', 'erp5_ingestion', 'erp5_ingestion_mysql_innodb_catalog',
'erp5_web', 'erp5_crm', 'erp5_dms') 'erp5_web', 'erp5_crm', 'erp5_dms')
def afterSetUp(self, quiet=QUIET, run=RUN_ALL_TEST): def afterSetUp(self):
""" """
Initialize the ERP5 site. Initialize the ERP5 site.
""" """
...@@ -914,11 +900,11 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -914,11 +900,11 @@ class TestIngestion(ERP5TypeTestCase):
attachment_list, ingested_document = self.verifyEmailedDocument() attachment_list, ingested_document = self.verifyEmailedDocument()
self.assertTrue(ingested_document.getRevision() > '1') self.assertTrue(ingested_document.getRevision() > '1')
def playSequence(self, step_list, quiet): def playSequence(self, step_list):
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)
def verifyEmailedMultipleDocuments(self): def verifyEmailedMultipleDocuments(self):
""" """
...@@ -984,12 +970,10 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -984,12 +970,10 @@ class TestIngestion(ERP5TypeTestCase):
## Tests ## Tests
################################## ##################################
def test_01_PreferenceSetup(self, quiet=QUIET, run=RUN_ALL_TEST): def test_01_PreferenceSetup(self):
""" """
Make sure that preferences are set up properly and accessible Make sure that preferences are set up properly and accessible
""" """
if not run: return
if not quiet: printAndLog('test_01_PreferenceSetup')
preference_tool = self.portal.portal_preferences preference_tool = self.portal.portal_preferences
conversion_dict = _getConversionServerDict() conversion_dict = _getConversionServerDict()
self.assertEquals(preference_tool.getPreferredOoodocServerAddress(), conversion_dict['hostname']) self.assertEquals(preference_tool.getPreferredOoodocServerAddress(), conversion_dict['hostname'])
...@@ -997,13 +981,11 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -997,13 +981,11 @@ class TestIngestion(ERP5TypeTestCase):
self.assertEquals(preference_tool.getPreferredDocumentFileNameRegularExpression(), FILE_NAME_REGULAR_EXPRESSION) self.assertEquals(preference_tool.getPreferredDocumentFileNameRegularExpression(), FILE_NAME_REGULAR_EXPRESSION)
self.assertEquals(preference_tool.getPreferredDocumentReferenceRegularExpression(), REFERENCE_REGULAR_EXPRESSION) self.assertEquals(preference_tool.getPreferredDocumentReferenceRegularExpression(), REFERENCE_REGULAR_EXPRESSION)
def test_02_FileExtensionRegistry(self, quiet=QUIET, run=RUN_ALL_TEST): def test_02_FileExtensionRegistry(self):
""" """
check if we successfully imported registry check if we successfully imported registry
and that it has all the entries we need and that it has all the entries we need
""" """
if not run: return
if not quiet: printAndLog('test_02_FileExtensionRegistry')
reg = self.portal.portal_contribution_registry reg = self.portal.portal_contribution_registry
correct_type_mapping = { correct_type_mapping = {
'doc' : 'Text', 'doc' : 'Text',
...@@ -1030,7 +1012,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1030,7 +1012,7 @@ class TestIngestion(ERP5TypeTestCase):
self.assertEquals(reg.findPortalTypeName(file_name, None, None), self.assertEquals(reg.findPortalTypeName(file_name, None, None),
portal_type) portal_type)
def test_03_TextDoc(self, quiet=QUIET, run=RUN_ALL_TEST): def test_03_TextDoc(self):
""" """
Test basic behaviour of a document: Test basic behaviour of a document:
- create empty document - create empty document
...@@ -1040,8 +1022,6 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1040,8 +1022,6 @@ class TestIngestion(ERP5TypeTestCase):
- check that it was properly converted - check that it was properly converted
- check if coordinates were extracted from file name - check if coordinates were extracted from file name
""" """
if not run: return
if not quiet: printAndLog('test_03_TextDoc')
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreateTextDocument' ,'stepCreateTextDocument'
,'stepCheckEmptyState' ,'stepCheckEmptyState'
...@@ -1054,9 +1034,9 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1054,9 +1034,9 @@ class TestIngestion(ERP5TypeTestCase):
,'stepTic' ,'stepTic'
,'stepCheckConvertedState' ,'stepCheckConvertedState'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_04_MetadataExtraction(self, quiet=QUIET, run=RUN_ALL_TEST): def test_04_MetadataExtraction(self):
""" """
Test metadata extraction from various sources: Test metadata extraction from various sources:
- from file name (doublecheck) - from file name (doublecheck)
...@@ -1069,24 +1049,20 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1069,24 +1049,20 @@ class TestIngestion(ERP5TypeTestCase):
NOTE: metadata of document (title, subject, description) NOTE: metadata of document (title, subject, description)
are no longer retrieved and set upon conversion are no longer retrieved and set upon conversion
""" """
if not run: return
if not quiet: printAndLog('test_04_MetadataExtraction')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepUploadTextFromContributionTool' ,'stepUploadTextFromContributionTool'
,'stepSetSimulatedDiscoveryScript' ,'stepSetSimulatedDiscoveryScript'
,'stepTic' ,'stepTic'
,'stepTestMetadataSetting' ,'stepTestMetadataSetting'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_041_MetadataEditing(self, quiet=QUIET, run=RUN_ALL_TEST): def test_041_MetadataEditing(self):
""" """
Check metadata in the object and in the ODF document Check metadata in the object and in the ODF document
Edit metadata on the object Edit metadata on the object
Download ODF, make sure it is changed Download ODF, make sure it is changed
""" """
if not run: return
if not quiet: printAndLog('test_04_MetadataEditing')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreateTextDocument' ,'stepCreateTextDocument'
,'stepUploadFromViewForm' ,'stepUploadFromViewForm'
...@@ -1096,7 +1072,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1096,7 +1072,7 @@ class TestIngestion(ERP5TypeTestCase):
,'stepEditMetadata' ,'stepEditMetadata'
,'stepCheckChangedMetadata' ,'stepCheckChangedMetadata'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
# Ingest various formats (xls, doc, sxi, ppt etc) # Ingest various formats (xls, doc, sxi, ppt etc)
# Verify that they are successfully converted # Verify that they are successfully converted
...@@ -1107,132 +1083,108 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1107,132 +1083,108 @@ class TestIngestion(ERP5TypeTestCase):
# implement _convertToBase (e.g. Image) # implement _convertToBase (e.g. Image)
# Verify that you can not upload file of the wrong format. # Verify that you can not upload file of the wrong format.
def test_05_FormatIngestionText(self, quiet=QUIET, run=RUN_ALL_TEST): def test_05_FormatIngestionText(self):
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreateTextDocument' ,'stepCreateTextDocument'
,'stepIngestTextFormats' ,'stepIngestTextFormats'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_05_FormatIngestionSpreadSheet(self, quiet=QUIET, run=RUN_ALL_TEST): def test_05_FormatIngestionSpreadSheet(self):
if not run: return
if not quiet: printAndLog('test_05_FormatIngestion')
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreateSpreadsheetDocument' ,'stepCreateSpreadsheetDocument'
,'stepIngestSpreadsheetFormats' ,'stepIngestSpreadsheetFormats'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_05_FormatIngestionPresentation(self, quiet=QUIET, run=RUN_ALL_TEST): def test_05_FormatIngestionPresentation(self):
if not run: return
if not quiet: printAndLog('test_05_FormatIngestion')
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreatePresentationDocument' ,'stepCreatePresentationDocument'
,'stepIngestPresentationFormats' ,'stepIngestPresentationFormats'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_05_FormatIngestionDrawing(self, quiet=QUIET, run=RUN_ALL_TEST): def test_05_FormatIngestionDrawing(self):
if not run: return
if not quiet: printAndLog('test_05_FormatIngestion')
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreateDrawingDocument' ,'stepCreateDrawingDocument'
,'stepIngestDrawingFormats' ,'stepIngestDrawingFormats'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_05_FormatIngestionPDF(self, quiet=QUIET, run=RUN_ALL_TEST): def test_05_FormatIngestionPDF(self):
if not run: return
if not quiet: printAndLog('test_05_FormatIngestion')
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreatePDFDocument' ,'stepCreatePDFDocument'
,'stepIngestPDFFormats' ,'stepIngestPDFFormats'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_05_FormatIngestionImage(self, quiet=QUIET, run=RUN_ALL_TEST): def test_05_FormatIngestionImage(self):
if not run: return
if not quiet: printAndLog('test_05_FormatIngestion')
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreateImageDocument' ,'stepCreateImageDocument'
,'stepIngestImageFormats' ,'stepIngestImageFormats'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_05_FormatIngestionFile(self, quiet=QUIET, run=RUN_ALL_TEST): def test_05_FormatIngestionFile(self):
if not run: return
if not quiet: printAndLog('test_05_FormatIngestion')
step_list = ['stepCleanUp' step_list = ['stepCleanUp'
,'stepCreateFileDocument' ,'stepCreateFileDocument'
,'stepIngestFileFormats' ,'stepIngestFileFormats'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
# Test generation of files in all possible formats # Test generation of files in all possible formats
# which means check if they have correct lists of available formats for export # which means check if they have correct lists of available formats for export
# actual generation is tested in oood tests # actual generation is tested in oood tests
# PDF and Image should be tested here # PDF and Image should be tested here
def test_06_FormatGenerationText(self, quiet=QUIET, run=RUN_ALL_TEST): def test_06_FormatGenerationText(self):
if not run: return
if not quiet: printAndLog('test_06_FormatGeneration')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreateTextDocument' ,'stepCreateTextDocument'
,'stepCheckTextDocumentExportList' ,'stepCheckTextDocumentExportList'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_06_FormatGenerationSpreadsheet(self, quiet=QUIET, run=RUN_ALL_TEST): def test_06_FormatGenerationSpreadsheet(self):
if not run: return
if not quiet: printAndLog('test_06_FormatGeneration')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreateSpreadsheetDocument' ,'stepCreateSpreadsheetDocument'
,'stepCheckSpreadsheetDocumentExportList' ,'stepCheckSpreadsheetDocumentExportList'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_06_FormatGenerationPresentation(self, quiet=QUIET, run=RUN_ALL_TEST): def test_06_FormatGenerationPresentation(self):
if not run: return
if not quiet: printAndLog('test_06_FormatGeneration')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreatePresentationDocument' ,'stepCreatePresentationDocument'
,'stepCheckPresentationDocumentExportList' ,'stepCheckPresentationDocumentExportList'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_06_FormatGenerationDrawing(self, quiet=QUIET, run=RUN_ALL_TEST): def test_06_FormatGenerationDrawing(self):
if not run: return
if not quiet: printAndLog('test_06_FormatGeneration')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreateDrawingDocument' ,'stepCreateDrawingDocument'
,'stepCheckDrawingDocumentExportList' ,'stepCheckDrawingDocumentExportList'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_06_FormatGenerationPdf(self, quiet=QUIET, run=RUN_ALL_TEST): def test_06_FormatGenerationPdf(self):
if not run: return
if not quiet: printAndLog('test_06_FormatGeneration')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreatePDFDocument' ,'stepCreatePDFDocument'
,'stepExportPDF' ,'stepExportPDF'
,'stepTic' ,'stepTic'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_06_FormatGenerationImage(self, quiet=QUIET, run=RUN_ALL_TEST): def test_06_FormatGenerationImage(self):
if not run: return
if not quiet: printAndLog('test_06_FormatGeneration')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreateImageDocument' ,'stepCreateImageDocument'
,'stepExportImage' ,'stepExportImage'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_08_Cache(self, quiet=QUIET, run=RUN_ALL_TEST): def test_08_Cache(self):
""" """
I don't know how to verify how cache works I don't know how to verify how cache works
""" """
def test_09_Contribute(self, quiet=QUIET, run=RUN_ALL_TEST): def test_09_Contribute(self):
""" """
Create content through portal_contributions Create content through portal_contributions
- use newContent to ingest various types - use newContent to ingest various types
...@@ -1242,16 +1194,14 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1242,16 +1194,14 @@ class TestIngestion(ERP5TypeTestCase):
- the files were converted - the files were converted
- metadata was read - metadata was read
""" """
if not run: return
if not quiet: printAndLog('test_09_Contribute')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepContributeFileListWithNoType' ,'stepContributeFileListWithNoType'
,'stepCleanUp' ,'stepCleanUp'
,'stepContributeFileListWithType' ,'stepContributeFileListWithType'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_10_MetadataSettingPreferenceOrder(self, quiet=QUIET, run=RUN_ALL_TEST): def test_10_MetadataSettingPreferenceOrder(self):
""" """
Set some metadata discovery scripts Set some metadata discovery scripts
Contribute a document, let it get metadata using default setup Contribute a document, let it get metadata using default setup
...@@ -1260,8 +1210,6 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1260,8 +1210,6 @@ class TestIngestion(ERP5TypeTestCase):
check that the right ones are there check that the right ones are there
change preference order, check again change preference order, check again
""" """
if not run: return
if not quiet: printAndLog('test_10_MetadataSettingPreferenceOrder')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepCreateTextDocument' ,'stepCreateTextDocument'
,'stepStraightUpload' ,'stepStraightUpload'
...@@ -1299,16 +1247,14 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1299,16 +1247,14 @@ class TestIngestion(ERP5TypeTestCase):
,'stepSetSimulatedDiscoveryScriptForOrdering' ,'stepSetSimulatedDiscoveryScriptForOrdering'
,'stepCheckMetadataSettingOrderUFCI' ,'stepCheckMetadataSettingOrderUFCI'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_11_EmailIngestion(self, quiet=QUIET, run=RUN_ALL_TEST): def test_11_EmailIngestion(self):
""" """
Simulate email piped to ERP5 by an MTA by uploading test email from file Simulate email piped to ERP5 by an MTA by uploading test email from file
Check that document objects are created and appropriate data are set Check that document objects are created and appropriate data are set
(owner, and anything discovered from user and mail body) (owner, and anything discovered from user and mail body)
""" """
if not run: return
if not quiet: printAndLog('test_11_EmailIngestion')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
# unknown sender # unknown sender
,'stepReceiveEmail' ,'stepReceiveEmail'
...@@ -1327,16 +1273,14 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1327,16 +1273,14 @@ class TestIngestion(ERP5TypeTestCase):
,'stepReceiveMultipleAttachmentsEmail' ,'stepReceiveMultipleAttachmentsEmail'
,'stepVerifyEmailedMultipleDocumentsMultipleContribution' ,'stepVerifyEmailedMultipleDocumentsMultipleContribution'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_12_UploadTextFromContributionTool(self, quiet=QUIET, run=RUN_ALL_TEST): def test_12_UploadTextFromContributionTool(self):
""" """
Make sure that when upload file from contribution tool, it creates a new Make sure that when upload file from contribution tool, it creates a new
document in document module. when reupload same filename file, then it document in document module. when reupload same filename file, then it
does not create a new document and update existing document. does not create a new document and update existing document.
""" """
if not run: return
if not quiet: printAndLog('test_12_ReUploadSameFilenameFile')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepUploadTextFromContributionTool' ,'stepUploadTextFromContributionTool'
,'stepCheckConvertingState' ,'stepCheckConvertingState'
...@@ -1347,7 +1291,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1347,7 +1291,7 @@ class TestIngestion(ERP5TypeTestCase):
,'stepReuploadTextFromContributionTool' ,'stepReuploadTextFromContributionTool'
,'stepUploadAnotherTextFromContributionTool' ,'stepUploadAnotherTextFromContributionTool'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def stepUploadTextFromContributionToolWithNonASCIIFilename(self, def stepUploadTextFromContributionToolWithNonASCIIFilename(self,
sequence=None, sequence_list=None, **kw): sequence=None, sequence_list=None, **kw):
...@@ -1385,24 +1329,20 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1385,24 +1329,20 @@ class TestIngestion(ERP5TypeTestCase):
self.assertEquals(context.getVersion(), '002') self.assertEquals(context.getVersion(), '002')
self.assertEquals(context.getSourceReference(), file_name) self.assertEquals(context.getSourceReference(), file_name)
def test_13_UploadTextFromContributionToolWithNonASCIIFilename(self, def test_13_UploadTextFromContributionToolWithNonASCIIFilename(self):
quiet=QUIET, run=RUN_ALL_TEST):
""" """
Make sure that when upload file from contribution tool, it creates a new Make sure that when upload file from contribution tool, it creates a new
document in document module. when reupload same filename file, then it document in document module. when reupload same filename file, then it
does not create a new document and update existing document. does not create a new document and update existing document.
""" """
if not run: return
if not quiet:
printAndLog('test_13_UploadTextFromContributionToolWithNonASCIIFilename')
step_list = [ 'stepCleanUp' step_list = [ 'stepCleanUp'
,'stepUploadTextFromContributionToolWithNonASCIIFilename' ,'stepUploadTextFromContributionToolWithNonASCIIFilename'
,'stepTic' ,'stepTic'
,'stepDiscoverFromFilenameWithNonASCIIFilename' ,'stepDiscoverFromFilenameWithNonASCIIFilename'
] ]
self.playSequence(step_list, quiet) self.playSequence(step_list)
def test_14_ContributionToolIndexation(self, quiet=QUIET, run=RUN_ALL_TEST): def test_14_ContributionToolIndexation(self):
""" """
Check that contribution tool is correctly indexed after business template Check that contribution tool is correctly indexed after business template
installation. installation.
......
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