From a2d033d747bc5df43d41bb28566095e8b57af49f Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Thu, 16 Dec 2010 09:43:43 +0000 Subject: [PATCH] rewrite testContributionRegistryTool create explicitely the predicates we want instead of relying on installation of BTs (that could include unwanted predicates). This test hence tests only the Tool, and not the BTs. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41488 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../tests/testContributionRegistryTool.py | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/product/ERP5/tests/testContributionRegistryTool.py b/product/ERP5/tests/testContributionRegistryTool.py index bda3d25a6a..065d9cc412 100644 --- a/product/ERP5/tests/testContributionRegistryTool.py +++ b/product/ERP5/tests/testContributionRegistryTool.py @@ -39,7 +39,7 @@ class TestContributionRegistryTool(ERP5TypeTestCase): return "Contribution Registry Tool" def getBusinessTemplateList(self): - return ('erp5_base', 'erp5_ingestion', 'erp5_web', 'erp5_dms',) + return ('erp5_base',) def afterSetUp(self): self.setUpTestScript() @@ -94,28 +94,59 @@ return predicate.getDestinationPortalType() def setUpPredicate(self): portal_contribution_registry = self.portal.portal_contribution_registry - if getattr(portal_contribution_registry, 'webpage_mimetype', None) is None: + + predicate_id = 'webpage_by_content_type' + if getattr(portal_contribution_registry, predicate_id, None) is None: predicate = portal_contribution_registry.newContent( portal_type='Contribution Predicate', - id='webpage_mimetype') - predicate._setMembershipCriterionCategoryList(['mime_type/text/html']) - predicate._setMembershipCriterionBaseCategoryList(['mime_type']) + id=predicate_id) + predicate.setCriterion('content_type', identity=['text/html']) predicate.setDestinationPortalType('Web Page') transaction.commit() self.tic() - if getattr(portal_contribution_registry, 'my_predicate', None) is None: + predicate_id = 'webpage_by_extension' + if getattr(portal_contribution_registry, predicate_id, None) is None: predicate = portal_contribution_registry.newContent( portal_type='Contribution Predicate', - id='my_predicate') - predicate._setMembershipCriterionCategoryList(['mime_type/message/rfc822']) - predicate._setMembershipCriterionBaseCategoryList(['mime_type']) - predicate.setCriterion('file_extension', identity=['eml']) + id=predicate_id) + predicate.setCriterion('extension_from_filename', identity=['html']) + predicate.setDestinationPortalType('Web Page') + transaction.commit() + self.tic() + + predicate_id = 'email_by_extension_and_content_type' + if getattr(portal_contribution_registry, predicate_id, None) is None: + predicate = portal_contribution_registry.newContent( + portal_type='Contribution Predicate', + id=predicate_id) + predicate.setCriterion('extension_from_filename', identity=['eml']) + predicate.setCriterion('content_type', identity=['message/rfc822']) predicate.setDestinationPortalType('Mail Message') predicate.setTestMethodId('IngestionFile_testEvent') transaction.commit() self.tic() + predicate_id = 'text_by_extension' + if getattr(portal_contribution_registry, predicate_id, None) is None: + predicate = portal_contribution_registry.newContent( + portal_type='Contribution Predicate', + id=predicate_id) + predicate.setCriterion('extension_from_filename', identity=['odt', 'txt']) + predicate.setDestinationPortalType('Text') + transaction.commit() + self.tic() + + predicate_id = 'image_by_extension' + if getattr(portal_contribution_registry, predicate_id, None) is None: + predicate = portal_contribution_registry.newContent( + portal_type='Contribution Predicate', + id=predicate_id) + predicate.setCriterion('extension_from_filename', identity=['jpg', 'png']) + predicate.setDestinationPortalType('Image') + transaction.commit() + self.tic() + def testFindPortalTypeName(self, quiet=0, run=run_all_test): tool = self.portal.portal_contribution_registry -- 2.30.9