[Erp5-report] r38803 nicolas - /erp5/trunk/products/ERP5OOo/tests/testIngestion.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Sep 30 14:56:58 CEST 2010


Author: nicolas
Date: Thu Sep 30 14:56:58 2010
New Revision: 38803

URL: http://svn.erp5.org?rev=38803&view=rev
Log:
Cleanup test

Modified:
    erp5/trunk/products/ERP5OOo/tests/testIngestion.py

Modified: erp5/trunk/products/ERP5OOo/tests/testIngestion.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testIngestion.py?rev=38803&r1=38802&r2=38803&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testIngestion.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testIngestion.py [utf8] Thu Sep 30 14:56:58 2010
@@ -51,16 +51,6 @@ TEST_FILES_HOME = os.path.join(os.path.d
 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}))?"
 
-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):
   return os.path.join(TEST_FILES_HOME, name)
@@ -76,10 +66,6 @@ class TestIngestion(ERP5TypeTestCase):
     ERP5 Document Management System - test file ingestion mechanism
   """
 
-  # pseudo constants
-  RUN_ALL_TEST = 1
-  QUIET = 0
-
   ##################################
   ##  ZopeTestCase Skeleton
   ##################################
@@ -98,7 +84,7 @@ class TestIngestion(ERP5TypeTestCase):
             'erp5_ingestion', 'erp5_ingestion_mysql_innodb_catalog',
             'erp5_web', 'erp5_crm', 'erp5_dms')
 
-  def afterSetUp(self, quiet=QUIET, run=RUN_ALL_TEST):
+  def afterSetUp(self):
     """
       Initialize the ERP5 site.
     """
@@ -796,7 +782,7 @@ class TestIngestion(ERP5TypeTestCase):
     portal = self.getPortal()
     for module in (portal.document_module, portal.image_module, portal.document_ingestion_module):
       module.manage_delObjects(map(None, module.objectIds()))
-    
+
   def stepContributeFileListWithType(self, sequence=None, sequence_list=None, **kw):
     """
       Contribute all kinds of files giving portal type explicitly
@@ -914,11 +900,11 @@ class TestIngestion(ERP5TypeTestCase):
     attachment_list, ingested_document = self.verifyEmailedDocument()
     self.assertTrue(ingested_document.getRevision() > '1')
 
-  def playSequence(self, step_list, quiet):
+  def playSequence(self, step_list):
     sequence_list = SequenceList()
     sequence_string = ' '.join(step_list)
     sequence_list.addSequenceString(sequence_string)
-    sequence_list.play(self, quiet=quiet)
+    sequence_list.play(self)
 
   def verifyEmailedMultipleDocuments(self):
     """
@@ -950,7 +936,7 @@ class TestIngestion(ERP5TypeTestCase):
       # check aggregate between 'Document Ingestion Message' and ingested document
       self.assertTrue(ingested_document in attachment_list)
     return attachment_list, ingested_document
-    
+
   def verifyEmailedDocument(self):
     """
       Basic checks for verifying a mailed-in document
@@ -961,7 +947,7 @@ class TestIngestion(ERP5TypeTestCase):
                                  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)
@@ -975,35 +961,31 @@ class TestIngestion(ERP5TypeTestCase):
     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
   ##################################
 
-  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
     """
-    if not run: return
-    if not quiet: printAndLog('test_01_PreferenceSetup')
     preference_tool = self.portal.portal_preferences
     conversion_dict = _getConversionServerDict()
     self.assertEquals(preference_tool.getPreferredOoodocServerAddress(), conversion_dict['hostname'])
     self.assertEquals(preference_tool.getPreferredOoodocServerPortNumber(), conversion_dict['port'])
     self.assertEquals(preference_tool.getPreferredDocumentFileNameRegularExpression(), FILE_NAME_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
       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
     correct_type_mapping = {
             'doc' : 'Text',
@@ -1030,7 +1012,7 @@ class TestIngestion(ERP5TypeTestCase):
       self.assertEquals(reg.findPortalTypeName(file_name, None, None),
                         portal_type)
 
-  def test_03_TextDoc(self, quiet=QUIET, run=RUN_ALL_TEST):
+  def test_03_TextDoc(self):
     """
       Test basic behaviour of a document:
       - create empty document
@@ -1040,8 +1022,6 @@ class TestIngestion(ERP5TypeTestCase):
       - check that it was properly converted
       - check if coordinates were extracted from file name
     """
-    if not run: return
-    if not quiet: printAndLog('test_03_TextDoc')
     step_list = ['stepCleanUp'
                  ,'stepCreateTextDocument'
                  ,'stepCheckEmptyState'
@@ -1054,9 +1034,9 @@ class TestIngestion(ERP5TypeTestCase):
                  ,'stepTic'
                  ,'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:
       - from file name (doublecheck)
@@ -1069,24 +1049,20 @@ class TestIngestion(ERP5TypeTestCase):
       NOTE: metadata of document (title, subject, description)
       are no longer retrieved and set upon conversion
     """
-    if not run: return
-    if not quiet: printAndLog('test_04_MetadataExtraction')
     step_list = [ 'stepCleanUp'
                  ,'stepUploadTextFromContributionTool'
                  ,'stepSetSimulatedDiscoveryScript'
                  ,'stepTic'
                  ,'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
       Edit metadata on the object
       Download ODF, make sure it is changed
     """
-    if not run: return
-    if not quiet: printAndLog('test_04_MetadataEditing')
     step_list = [ 'stepCleanUp'
                  ,'stepCreateTextDocument'
                  ,'stepUploadFromViewForm'
@@ -1096,7 +1072,7 @@ class TestIngestion(ERP5TypeTestCase):
                  ,'stepEditMetadata'
                  ,'stepCheckChangedMetadata'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
   #    Ingest various formats (xls, doc, sxi, ppt etc)
   #    Verify that they are successfully converted
@@ -1107,132 +1083,108 @@ class TestIngestion(ERP5TypeTestCase):
   #      implement _convertToBase (e.g. Image)
   #    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'
                  ,'stepCreateTextDocument'
                  ,'stepIngestTextFormats'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_05_FormatIngestionSpreadSheet(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_05_FormatIngestion')
+  def test_05_FormatIngestionSpreadSheet(self):
     step_list = ['stepCleanUp'
                  ,'stepCreateSpreadsheetDocument'
                  ,'stepIngestSpreadsheetFormats'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_05_FormatIngestionPresentation(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_05_FormatIngestion')
+  def test_05_FormatIngestionPresentation(self):
     step_list = ['stepCleanUp'
                  ,'stepCreatePresentationDocument'
                  ,'stepIngestPresentationFormats'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_05_FormatIngestionDrawing(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_05_FormatIngestion')
+  def test_05_FormatIngestionDrawing(self):
     step_list = ['stepCleanUp'
                  ,'stepCreateDrawingDocument'
                  ,'stepIngestDrawingFormats'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_05_FormatIngestionPDF(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_05_FormatIngestion')
+  def test_05_FormatIngestionPDF(self):
     step_list = ['stepCleanUp'
                  ,'stepCreatePDFDocument'
                  ,'stepIngestPDFFormats'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_05_FormatIngestionImage(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_05_FormatIngestion')
+  def test_05_FormatIngestionImage(self):
     step_list = ['stepCleanUp'
                  ,'stepCreateImageDocument'
                  ,'stepIngestImageFormats'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_05_FormatIngestionFile(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_05_FormatIngestion')
+  def test_05_FormatIngestionFile(self):
     step_list = ['stepCleanUp'
                  ,'stepCreateFileDocument'
                  ,'stepIngestFileFormats'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
   # Test generation of files in all possible formats
   # which means check if they have correct lists of available formats for export
   # actual generation is tested in oood tests
   # PDF and Image should be tested here
-  def test_06_FormatGenerationText(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_06_FormatGeneration')
+  def test_06_FormatGenerationText(self):
     step_list = [ 'stepCleanUp'
                  ,'stepCreateTextDocument'
                  ,'stepCheckTextDocumentExportList'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_06_FormatGenerationSpreadsheet(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_06_FormatGeneration')
+  def test_06_FormatGenerationSpreadsheet(self):
     step_list = [ 'stepCleanUp'
                  ,'stepCreateSpreadsheetDocument'
                  ,'stepCheckSpreadsheetDocumentExportList'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_06_FormatGenerationPresentation(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_06_FormatGeneration')
+  def test_06_FormatGenerationPresentation(self):
     step_list = [ 'stepCleanUp'
                  ,'stepCreatePresentationDocument'
                  ,'stepCheckPresentationDocumentExportList'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_06_FormatGenerationDrawing(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_06_FormatGeneration')
+  def test_06_FormatGenerationDrawing(self):
     step_list = [ 'stepCleanUp'
                  ,'stepCreateDrawingDocument'
                  ,'stepCheckDrawingDocumentExportList'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_06_FormatGenerationPdf(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_06_FormatGeneration')
+  def test_06_FormatGenerationPdf(self):
     step_list = [ 'stepCleanUp'
                  ,'stepCreatePDFDocument'
                  ,'stepExportPDF'
                  ,'stepTic'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def test_06_FormatGenerationImage(self, quiet=QUIET, run=RUN_ALL_TEST):
-    if not run: return
-    if not quiet: printAndLog('test_06_FormatGeneration')
+  def test_06_FormatGenerationImage(self):
     step_list = [ 'stepCleanUp'
                  ,'stepCreateImageDocument'
                  ,'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
     """
 
-  def test_09_Contribute(self, quiet=QUIET, run=RUN_ALL_TEST):
+  def test_09_Contribute(self):
     """
       Create content through portal_contributions
       - use newContent to ingest various types 
@@ -1242,16 +1194,14 @@ class TestIngestion(ERP5TypeTestCase):
         - the files were converted
         - metadata was read
     """
-    if not run: return
-    if not quiet: printAndLog('test_09_Contribute')
     step_list = [ 'stepCleanUp'
                  ,'stepContributeFileListWithNoType'
                  ,'stepCleanUp'
                  ,'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
       Contribute a document, let it get metadata using default setup
@@ -1260,8 +1210,6 @@ class TestIngestion(ERP5TypeTestCase):
       check that the right ones are there
       change preference order, check again
     """
-    if not run: return
-    if not quiet: printAndLog('test_10_MetadataSettingPreferenceOrder')
     step_list = [ 'stepCleanUp' 
                  ,'stepCreateTextDocument'
                  ,'stepStraightUpload'
@@ -1299,16 +1247,14 @@ class TestIngestion(ERP5TypeTestCase):
                  ,'stepSetSimulatedDiscoveryScriptForOrdering'
                  ,'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
       Check that document objects are created and appropriate data are set
       (owner, and anything discovered from user and mail body)
     """
-    if not run: return
-    if not quiet: printAndLog('test_11_EmailIngestion')
     step_list = [ 'stepCleanUp'
                  # unknown sender
                  ,'stepReceiveEmail'
@@ -1327,16 +1273,14 @@ class TestIngestion(ERP5TypeTestCase):
                  ,'stepReceiveMultipleAttachmentsEmail'
                  ,'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
       document in document module. when reupload same filename file, then it
       does not create a new document and update existing document.
     """
-    if not run: return
-    if not quiet: printAndLog('test_12_ReUploadSameFilenameFile')
     step_list = [ 'stepCleanUp'
                  ,'stepUploadTextFromContributionTool'
                  ,'stepCheckConvertingState'
@@ -1347,9 +1291,9 @@ class TestIngestion(ERP5TypeTestCase):
                  ,'stepReuploadTextFromContributionTool'
                  ,'stepUploadAnotherTextFromContributionTool'
                 ]
-    self.playSequence(step_list, quiet)
+    self.playSequence(step_list)
 
-  def stepUploadTextFromContributionToolWithNonASCIIFilename(self, 
+  def stepUploadTextFromContributionToolWithNonASCIIFilename(self,
                                  sequence=None, sequence_list=None, **kw):
     """
       Upload a file from contribution.
@@ -1359,7 +1303,7 @@ class TestIngestion(ERP5TypeTestCase):
     sequence.edit(document_id=document.getId())
     transaction.commit()
 
-  def stepDiscoverFromFilenameWithNonASCIIFilename(self, 
+  def stepDiscoverFromFilenameWithNonASCIIFilename(self,
                                  sequence=None, sequence_list=None, **kw):
     """
       Upload a file using contribution tool. This should trigger metadata
@@ -1385,24 +1329,20 @@ class TestIngestion(ERP5TypeTestCase):
     self.assertEquals(context.getVersion(), '002')
     self.assertEquals(context.getSourceReference(), file_name)
 
-  def test_13_UploadTextFromContributionToolWithNonASCIIFilename(self, 
-                                           quiet=QUIET, run=RUN_ALL_TEST):
+  def test_13_UploadTextFromContributionToolWithNonASCIIFilename(self):
     """
       Make sure that when upload file from contribution tool, it creates a new
       document in document module. when reupload same filename file, then it
       does not create a new document and update existing document.
     """
-    if not run: return
-    if not quiet:
-      printAndLog('test_13_UploadTextFromContributionToolWithNonASCIIFilename')
     step_list = [ 'stepCleanUp'
                  ,'stepUploadTextFromContributionToolWithNonASCIIFilename'
                  ,'stepTic'
                  ,'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
     installation.
@@ -1449,7 +1389,7 @@ class TestIngestion(ERP5TypeTestCase):
     user = self.createUser(reference='contributor1')
     organisation = self.portal.organisation_module.newContent(**dict(group='anybody',
                                                                      site='site/arctic/spitsbergen'))
-         
+
     user.setSubordinationValue(organisation)
     portal.document_module.manage_setLocalRoles('contributor1', ['Assignor',])
     self.stepTic()




More information about the Erp5-report mailing list