Commit 575a0d2d authored by Jérome Perrin's avatar Jérome Perrin

remove quiet and run_all tests from signatures

replace self.getPoral() by self.portal


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35159 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 724794f2
...@@ -34,8 +34,6 @@ from Acquisition import aq_base ...@@ -34,8 +34,6 @@ from Acquisition import aq_base
class CodingStyleTestCase(ERP5TypeTestCase): class CodingStyleTestCase(ERP5TypeTestCase):
"""XXX """XXX
""" """
run_all_test = 1
quiet = 0
manager_username = 'zope' manager_username = 'zope'
manager_password = 'zope' manager_password = 'zope'
website_id = 'test' website_id = 'test'
...@@ -63,24 +61,18 @@ class CodingStyleTestCase(ERP5TypeTestCase): ...@@ -63,24 +61,18 @@ class CodingStyleTestCase(ERP5TypeTestCase):
return self.getBusinessTemplateList()[-1:] return self.getBusinessTemplateList()[-1:]
def afterSetUp(self): def afterSetUp(self):
portal = self.getPortal() portal = self.portal
uf = portal.acl_users uf = portal.acl_users
uf._doAddUser(self.manager_username, self.manager_password, ['Manager'], []) uf._doAddUser(self.manager_username, self.manager_password, ['Manager'], [])
self.login(self.manager_username) self.login(self.manager_username)
self.portal_id = self.portal.getId()
def test_01_SkinCodingStyle(self, quiet=quiet, run=run_all_test): def test_SkinCodingStyle(self):
""" """
Find all skin items of business templates to be checked Find all skin items of business templates to be checked
and gather all consistency messages. and gather all consistency messages.
""" """
if not run: return
if not quiet:
message = '\ntest_01_CodingStyle'
ZopeTestCase._print(message)
# Find the list if skins to test - we only test the last business template # Find the list if skins to test - we only test the last business template
portal_templates = self.getPortal().portal_templates portal_templates = self.getPortal().portal_templates
skin_id_list = [] skin_id_list = []
...@@ -92,7 +84,7 @@ class CodingStyleTestCase(ERP5TypeTestCase): ...@@ -92,7 +84,7 @@ class CodingStyleTestCase(ERP5TypeTestCase):
message_list = [] message_list = []
# Test skins # Test skins
portal_skins = self.getPortal().portal_skins portal_skins = self.portal.portal_skins
for skin_id in skin_id_list: for skin_id in skin_id_list:
skin = portal_skins[skin_id] skin = portal_skins[skin_id]
for document in skin.objectValues(): for document in skin.objectValues():
......
...@@ -26,12 +26,10 @@ ...@@ -26,12 +26,10 @@
# #
############################################################################## ##############################################################################
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.utils import installRealClassTool from Products.ERP5Type.tests.utils import installRealClassTool
from App.config import getConfiguration from App.config import getConfiguration
from zLOG import LOG
try: try:
from transaction import get as get_transaction from transaction import get as get_transaction
...@@ -39,50 +37,32 @@ except ImportError: ...@@ -39,50 +37,32 @@ except ImportError:
pass pass
class TestClassTool(ERP5TypeTestCase): class TestClassTool(ERP5TypeTestCase):
run_all_test = 1
quiet = 1
def getTitle(self): def getTitle(self):
return "Class Tool" return "Class Tool"
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
installRealClassTool(self.getPortal()) installRealClassTool(self.portal)
def login(self, quiet=0, run=run_all_test): def login(self):
uf = self.getPortal().acl_users uf = self.portal.acl_users
uf._doAddUser('seb', '', ['Manager'], []) uf._doAddUser('seb', '', ['Manager'], [])
uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], []) uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], [])
user = uf.getUserById('seb').__of__(uf) user = uf.getUserById('seb').__of__(uf)
newSecurityManager(None, user) newSecurityManager(None, user)
def test_01_CheckClassTool(self, quiet=quiet, run=run_all_test): def test_01_CheckClassTool(self):
""" """
Make sure that portal_classes exists Make sure that portal_classes exists
""" """
if not run: portal = self.portal
return
if not quiet:
message = '\nCheck ClassTool '
ZopeTestCase._print(message)
LOG('Testing... ',0,message)
portal = self.getPortal()
self.assertNotEqual(None,getattr(portal,'portal_classes',None)) self.assertNotEqual(None,getattr(portal,'portal_classes',None))
get_transaction().commit() get_transaction().commit()
def test_02_CheckFileWriteIsTransactional(self, quiet=quiet, def test_02_CheckFileWriteIsTransactional(self):
run=run_all_test): portal = self.portal
if not run:
return
if not quiet:
message = '\nCheck File Transaction'
ZopeTestCase._print(message)
LOG('Testing... ',0,message)
portal = self.getPortal()
portal_classes = portal.portal_classes portal_classes = portal.portal_classes
self.assertEqual(portal_classes.getLocalDocumentList(), [], self.assertEqual(portal_classes.getLocalDocumentList(), [],
......
...@@ -29,18 +29,14 @@ ...@@ -29,18 +29,14 @@
import transaction import transaction
import unittest import unittest
import os
from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
class TestConstraint(PropertySheetTestCase): class TestConstraint(PropertySheetTestCase):
run_all_test = 1
quiet = not os.environ.get('VERBOSE', 0)
object_portal_type = "Organisation" object_portal_type = "Organisation"
object_content_portal_type = "Address" object_content_portal_type = "Address"
object_title = "Title test" object_title = "Title test"
...@@ -305,11 +301,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -305,11 +301,10 @@ class TestConstraint(PropertySheetTestCase):
id='default_constraint', id='default_constraint',
description='constraint test') description='constraint test')
def test_01_Constraint(self, quiet=quiet, run=run_all_test): def test_01_Constraint(self):
""" """
Test default Constraint class Test default Constraint class
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint without any configuration # Test Constraint without any configuration
sequence_string = '\ sequence_string = '\
...@@ -319,7 +314,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -319,7 +314,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def stepCreatePropertyExistence0(self, sequence=None, def stepCreatePropertyExistence0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -379,11 +374,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -379,11 +374,10 @@ class TestConstraint(PropertySheetTestCase):
description='propertyExistence test', description='propertyExistence test',
title=None) title=None)
def test_02_PropertyExistence(self, quiet=quiet, run=run_all_test): def test_02_PropertyExistence(self):
""" """
Test property existence Test property existence
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint without any configuration # Test Constraint without any configuration
sequence_string = '\ sequence_string = '\
...@@ -460,7 +454,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -460,7 +454,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def stepCreatePropertyTypeValidity(self, sequence=None, def stepCreatePropertyTypeValidity(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -472,11 +466,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -472,11 +466,10 @@ class TestConstraint(PropertySheetTestCase):
id='property_type_validity', id='property_type_validity',
description='propertyTypeValidity test') description='propertyTypeValidity test')
def test_03_PropertyTypeValidity(self, quiet=quiet, run=run_all_test): def test_03_PropertyTypeValidity(self):
""" """
Test property type validity Test property type validity
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint without any configuration # Test Constraint without any configuration
sequence_string = '\ sequence_string = '\
...@@ -561,7 +554,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -561,7 +554,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def stepCreateAttributeEquality0(self, sequence=None, def stepCreateAttributeEquality0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -584,11 +577,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -584,11 +577,10 @@ class TestConstraint(PropertySheetTestCase):
description='AttributeEquality test', description='AttributeEquality test',
title=self.object_title) title=self.object_title)
def test_04_AttributeEquality(self, quiet=quiet, run=run_all_test): def test_04_AttributeEquality(self):
""" """
Test attribute equality Test attribute equality
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint without any configuration # Test Constraint without any configuration
sequence_string = '\ sequence_string = '\
...@@ -627,7 +619,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -627,7 +619,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def stepCreateCategoryExistence0(self, sequence=None, def stepCreateCategoryExistence0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -673,11 +665,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -673,11 +665,10 @@ class TestConstraint(PropertySheetTestCase):
group=None, group=None,
portal_type = ('Organisation', )) portal_type = ('Organisation', ))
def test_05_CategoryExistence(self, quiet=quiet, run=run_all_test): def test_05_CategoryExistence(self):
""" """
Test category existence Test category existence
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint without any configuration # Test Constraint without any configuration
sequence_string = '\ sequence_string = '\
...@@ -743,7 +734,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -743,7 +734,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def stepCreateCategoryMembershipArity0(self, sequence=None, def stepCreateCategoryMembershipArity0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -815,11 +806,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -815,11 +806,10 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Category', ), portal_type=('Category', ),
base_category=('group', )) base_category=('group', ))
def test_06_CategoryMembershipArity(self, quiet=quiet, run=run_all_test): def test_06_CategoryMembershipArity(self):
""" """
Test category existence Test category existence
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint with min=0, max=0 # Test Constraint with min=0, max=0
sequence_string = '\ sequence_string = '\
...@@ -966,7 +956,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -966,7 +956,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def test_CategoryMembershipArityNoMax(self): def test_CategoryMembershipArityNoMax(self):
obj = self._makeOne() obj = self._makeOne()
...@@ -1041,11 +1031,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1041,11 +1031,10 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Organisation', ), portal_type=('Organisation', ),
base_category=('group', )) base_category=('group', ))
def test_07_CategoryRelatedMembershipArity(self, quiet=quiet, run=run_all_test): def test_07_CategoryRelatedMembershipArity(self):
""" """
Test related category existence Test related category existence
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint with min=0, max=0 # Test Constraint with min=0, max=0
sequence_string = '\ sequence_string = '\
...@@ -1110,7 +1099,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1110,7 +1099,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintFailed \ CheckIfConstraintFailed \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def test_RelatedCategoryMembershipArityNoMax(self): def test_RelatedCategoryMembershipArityNoMax(self):
related_obj = self._makeOne() related_obj = self._makeOne()
...@@ -1304,12 +1293,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1304,12 +1293,10 @@ class TestConstraint(PropertySheetTestCase):
content_object = content_object, content_object = content_object,
) )
def test_ContentExistenceConstraint(self, quiet=quiet, run=run_all_test): def test_ContentExistenceConstraint(self):
""" """
Tests Content Existence Tests Content Existence
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint without any content # Test Constraint without any content
sequence_string = '\ sequence_string = '\
...@@ -1328,7 +1315,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1328,7 +1315,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def stepCreateStringAttributeMatch(self, sequence=None, sequence_list=None, **kw): def stepCreateStringAttributeMatch(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -1362,11 +1349,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1362,11 +1349,10 @@ class TestConstraint(PropertySheetTestCase):
object = object, object = object,
) )
def test_StringAttributeMatchConstraint(self, quiet=quiet, run=run_all_test): def test_StringAttributeMatchConstraint(self):
""" """
Tests Content Existence Tests string attribute match
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint with empty Title # Test Constraint with empty Title
sequence_string = '\ sequence_string = '\
...@@ -1396,7 +1382,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1396,7 +1382,7 @@ class TestConstraint(PropertySheetTestCase):
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def test_RegisterWithPropertySheet(self): def test_RegisterWithPropertySheet(self):
# constraint are registred in property sheets # constraint are registred in property sheets
...@@ -1522,11 +1508,10 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1522,11 +1508,10 @@ class TestConstraint(PropertySheetTestCase):
condition="object/getTitle") condition="object/getTitle")
sequence.set('constraint', constraint) sequence.set('constraint', constraint)
def test_08_AttributeUnicity(self, quiet=quiet, run=run_all_test): def test_08_AttributeUnicity(self):
""" """
Test attribute unicity Test attribute unicity
""" """
if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test Constraint without unicity on title # Test Constraint without unicity on title
sequence_string = '\ sequence_string = '\
...@@ -1560,7 +1545,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1560,7 +1545,7 @@ class TestConstraint(PropertySheetTestCase):
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -34,10 +34,9 @@ import sys ...@@ -34,10 +34,9 @@ import sys
import transaction import transaction
from random import randint from random import randint
from Acquisition import aq_base from Acquisition import aq_base
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import DummyLocalizer from Products.ERP5Type.tests.utils import DummyLocalizer
from zLOG import LOG, INFO from zLOG import INFO
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.ERP5Type.tests.utils import LogInterceptor from Products.ERP5Type.tests.utils import LogInterceptor
from Products.CMFCore.WorkflowCore import WorkflowException from Products.CMFCore.WorkflowCore import WorkflowException
...@@ -102,9 +101,6 @@ class %(property_sheet_name)s: ...@@ -102,9 +101,6 @@ class %(property_sheet_name)s:
class TestERP5Type(PropertySheetTestCase, LogInterceptor): class TestERP5Type(PropertySheetTestCase, LogInterceptor):
"""Tests ERP5TypeInformation and per portal type generated accessors. """Tests ERP5TypeInformation and per portal type generated accessors.
""" """
run_all_test = 1
quiet = 1
# Some helper methods # Some helper methods
def getTitle(self): def getTitle(self):
...@@ -137,8 +133,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -137,8 +133,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
transaction.commit() transaction.commit()
self.tic() self.tic()
def loginWithNoRole(self, quiet=0, run=run_all_test): def loginWithNoRole(self):
uf = self.getPortal().acl_users uf = self.portal.acl_users
uf._doAddUser('ac', '', [], []) uf._doAddUser('ac', '', [], [])
user = uf.getUserById('ac').__of__(uf) user = uf.getUserById('ac').__of__(uf)
newSecurityManager(None, user) newSecurityManager(None, user)
...@@ -194,9 +190,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -194,9 +190,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEquals(business_template.getTitle(), test_string) self.assertEquals(business_template.getTitle(), test_string)
# Test Dynamic Code Generation # Test Dynamic Code Generation
def test_02_AqDynamic(self, quiet=quiet, run=run_all_test): def test_02_AqDynamic(self):
if not run: return
portal = self.getPortal()
module = self.getPersonModule() module = self.getPersonModule()
person = module.newContent(id='1', portal_type='Person') person = module.newContent(id='1', portal_type='Person')
from Products.ERP5Type import Document from Products.ERP5Type import Document
...@@ -210,9 +204,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -210,9 +204,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# Person class should now have method getFirstName # Person class should now have method getFirstName
self.assertTrue(hasattr(person, 'getFirstName')) self.assertTrue(hasattr(person, 'getFirstName'))
def test_03_NewTempObject(self, quiet=quiet, run=run_all_test): def test_03_NewTempObject(self):
if not run: return portal = self.portal
portal = self.getPortal()
from Products.ERP5Type.Document import newTempPerson from Products.ERP5Type.Document import newTempPerson
o = newTempPerson(portal, 1.2) o = newTempPerson(portal, 1.2)
...@@ -227,12 +220,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -227,12 +220,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEquals(str(o.getId()), str(-123)) self.assertEquals(str(o.getId()), str(-123))
# Try to edit with any property and then get it with getProperty # Try to edit with any property and then get it with getProperty
o = newTempOrganisation(portal,'a') o = newTempOrganisation(portal,'a')
o.edit(tutu='toto') o.edit(tutu='toto')
self.assertEquals(o.getProperty('tutu'), 'toto') self.assertEquals(o.getProperty('tutu'), 'toto')
# Same thing with an integer # Same thing with an integer
o = newTempOrganisation(portal,'b') o = newTempOrganisation(portal,'b')
o.edit(tata=123) o.edit(tata=123)
self.assertEquals(o.getProperty('tata'), 123) self.assertEquals(o.getProperty('tata'), 123)
...@@ -240,7 +233,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -240,7 +233,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEquals(o.isTempObject(), 1) self.assertEquals(o.isTempObject(), 1)
# Create a subobject and make sure it is a Temp Object # Create a subobject and make sure it is a Temp Object
a = o.newContent(portal_type = 'Telephone') a = o.newContent(portal_type = 'Telephone')
self.assertEquals(a.isTempObject(), 1) self.assertEquals(a.isTempObject(), 1)
# Test newContent with the temp_object parameter # Test newContent with the temp_object parameter
...@@ -333,7 +326,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -333,7 +326,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.portal.portal_url.getRelativeContentPath(child11)) self.portal.portal_url.getRelativeContentPath(child11))
def test_04_CategoryAccessors(self, quiet=quiet, run=run_all_test): def test_04_CategoryAccessors(self):
""" """
This test provides basic testing of category This test provides basic testing of category
accessors using the region base category. accessors using the region base category.
...@@ -354,8 +347,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -354,8 +347,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
of a region and should thus be accessible from the region of a region and should thus be accessible from the region
category through getRegionRelated accessors category through getRegionRelated accessors
""" """
if not run: return
portal = self.getPortal()
region_category = self.getPortal().portal_categories.region region_category = self.getPortal().portal_categories.region
category_title = "Solar System" category_title = "Solar System"
...@@ -435,7 +426,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -435,7 +426,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertTrue(person_object.hasActivity()) self.assertTrue(person_object.hasActivity())
self.tic() self.tic()
def test_05_setProperty(self, quiet=quiet, run=run_all_test): def test_05_setProperty(self):
""" """
In this test we create a subobject (ie. a phone number) In this test we create a subobject (ie. a phone number)
and show the difference between calling getProperty and and show the difference between calling getProperty and
...@@ -451,8 +442,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -451,8 +442,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
using getProperty / setProperty as a generic way to use using getProperty / setProperty as a generic way to use
accessors from subobjects. accessors from subobjects.
""" """
if not run: return
portal = self.getPortal()
module = self.getOrganisationModule() module = self.getOrganisationModule()
organisation = module.newContent(id='1', portal_type='Organisation') organisation = module.newContent(id='1', portal_type='Organisation')
organisation.setDefaultTelephoneText('+55(0)66-5555') organisation.setDefaultTelephoneText('+55(0)66-5555')
...@@ -467,9 +456,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -467,9 +456,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEquals(organisation.default_telephone.corporate_name,'Toto') self.assertEquals(organisation.default_telephone.corporate_name,'Toto')
self.assertEquals(organisation.default_telephone.getProperty('corporate_name'),'Toto') self.assertEquals(organisation.default_telephone.getProperty('corporate_name'),'Toto')
def test_06_CachingMethod(self, quiet=quiet, run=run_all_test): def test_06_CachingMethod(self):
"""Tests Caching methods.""" """Tests Caching methods."""
if not run: return
cached_var = cached_var_orig = 'cached_var1' cached_var = cached_var_orig = 'cached_var1'
def _cache(): def _cache():
...@@ -488,11 +476,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -488,11 +476,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
clearCache() clearCache()
self.assertEquals(cache(), cached_var) self.assertEquals(cache(), cached_var)
def test_07_afterCloneScript(self, quiet=quiet, run=run_all_test): def test_07_afterCloneScript(self):
"""manage_afterClone can call a type based script.""" """manage_afterClone can call a type based script."""
if not run: return
# setup the script for Person portal type # setup the script for Person portal type
custom_skin = self.getPortal().portal_skins.custom custom_skin = self.portal.portal_skins.custom
method_id = 'Person_afterClone' method_id = 'Person_afterClone'
if method_id in custom_skin.objectIds(): if method_id in custom_skin.objectIds():
custom_skin.manage_delObjects([method_id]) custom_skin.manage_delObjects([method_id])
...@@ -534,10 +521,9 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -534,10 +521,9 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
new_orga = folder[new_id] new_orga = folder[new_id]
self.assertEquals(new_orga.getTitle(), 'something') self.assertEquals(new_orga.getTitle(), 'something')
def test_08_AccessorGeneration(self, quiet=quiet, run=run_all_test): def test_08_AccessorGeneration(self):
"""Tests accessor generation doesn't generate error messages. """Tests accessor generation doesn't generate error messages.
""" """
if not run: return
from Products.ERP5Type.Base import _aq_reset from Products.ERP5Type.Base import _aq_reset
_aq_reset() _aq_reset()
self._catch_log_errors(ignored_level=INFO) self._catch_log_errors(ignored_level=INFO)
...@@ -549,13 +535,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -549,13 +535,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
finally: finally:
self._ignore_log_errors() self._ignore_log_errors()
def test_09_RenameObjects(self, quiet=quiet, run=run_all_test): def test_09_RenameObjects(self):
"""Test object renaming. """Test object renaming.
As we overloaded some parts of OFS, it's better to test again some basic As we overloaded some parts of OFS, it's better to test again some basic
features. features.
""" """
if not run: return
folder = self.getOrganisationModule() folder = self.getOrganisationModule()
id_list = [chr(x) for x in range(ord('a'), ord('z')+1)] id_list = [chr(x) for x in range(ord('a'), ord('z')+1)]
for id_ in id_list: for id_ in id_list:
...@@ -576,13 +561,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -576,13 +561,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
new_id = '%s_new' % id_ new_id = '%s_new' % id_
self.assertEquals(folder._getOb(new_id).getId(), new_id) self.assertEquals(folder._getOb(new_id).getId(), new_id)
def test_10_ConstraintNotFound(self, quiet=quiet, run=run_all_test): def test_10_ConstraintNotFound(self):
""" """
When a Constraint is not found while importing a PropertySheet, When a Constraint is not found while importing a PropertySheet,
AttributeError was raised, and generated a infinite loop. AttributeError was raised, and generated a infinite loop.
This is a test to make sure this will not happens any more This is a test to make sure this will not happens any more
""" """
if not run: return
text = """ text = """
class TestPropertySheet: class TestPropertySheet:
\"\"\" \"\"\"
...@@ -611,7 +595,7 @@ class TestPropertySheet: ...@@ -611,7 +595,7 @@ class TestPropertySheet:
organisation = self.assertRaises(ConstraintNotFound, folder.newContent, organisation = self.assertRaises(ConstraintNotFound, folder.newContent,
portal_type='Organisation') portal_type='Organisation')
def test_11_valueAccessor(self, quiet=quiet, run=run_all_test): def test_11_valueAccessor(self):
""" """
The purpose of this test is to make sure that category accessors The purpose of this test is to make sure that category accessors
work as expected. work as expected.
...@@ -625,15 +609,8 @@ class TestPropertySheet: ...@@ -625,15 +609,8 @@ class TestPropertySheet:
The test is implemented for both Category and Value The test is implemented for both Category and Value
accessors. accessors.
""" """
if not run: return
if not quiet:
message = 'Test Category setters'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
# Create a few categories # Create a few categories
region_category = self.getPortal().portal_categories.region region_category = self.portal.portal_categories.region
alpha = region_category.newContent( alpha = region_category.newContent(
portal_type = "Category", portal_type = "Category",
id = "alpha", id = "alpha",
...@@ -774,20 +751,13 @@ class TestPropertySheet: ...@@ -774,20 +751,13 @@ class TestPropertySheet:
person.setRegionUid([person.getUid(), alpha.getUid(), beta.getUid()]) person.setRegionUid([person.getUid(), alpha.getUid(), beta.getUid()])
self.assertEquals(person.getRegionList(), [person.getRelativeUrl(), 'alpha', 'beta']) self.assertEquals(person.getRegionList(), [person.getRelativeUrl(), 'alpha', 'beta'])
def test_12_listAccessor(self, quiet=quiet, run=run_all_test): def test_12_listAccessor(self):
""" """
The purpose of this test is to make sure that accessor for The purpose of this test is to make sure that accessor for
sequence types support the same kind of semantics as the sequence types support the same kind of semantics as the
one on categories. We use 'subject' of the DublinCore propertysheet one on categories. We use 'subject' of the DublinCore propertysheet
on organisation documents for this test. on organisation documents for this test.
""" """
if not run: return
if not quiet:
message = 'Test Category setters'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
# Create a new person # Create a new person
module = self.getPersonModule() module = self.getPersonModule()
person = module.newContent(portal_type='Person') person = module.newContent(portal_type='Person')
...@@ -821,7 +791,7 @@ class TestPropertySheet: ...@@ -821,7 +791,7 @@ class TestPropertySheet:
self.assertEquals(result, ['alpha', 'beta']) self.assertEquals(result, ['alpha', 'beta'])
self.assertEquals(person.getSubjectList(), ['alpha', 'beta']) self.assertEquals(person.getSubjectList(), ['alpha', 'beta'])
def test_13_acquiredAccessor(self, quiet=quiet, run=run_all_test): def test_13_acquiredAccessor(self):
""" """
The purpose of this test is to make sure that accessor for The purpose of this test is to make sure that accessor for
sequence types support the same kind of semantics as the sequence types support the same kind of semantics as the
...@@ -843,7 +813,6 @@ class TestPropertySheet: ...@@ -843,7 +813,6 @@ class TestPropertySheet:
""" """
Tests that the default value is returned correctly Tests that the default value is returned correctly
""" """
portal = self.getPortal()
module = self.getPersonModule() module = self.getPersonModule()
person = module.newContent(id='1', portal_type='Person') person = module.newContent(id='1', portal_type='Person')
...@@ -875,12 +844,10 @@ class TestPropertySheet: ...@@ -875,12 +844,10 @@ class TestPropertySheet:
self.assertEquals(person.getProperty(property_name, 'foo'), 'foo') self.assertEquals(person.getProperty(property_name, 'foo'), 'foo')
self.assertEquals(person.getProperty(property_name, d='foo'), 'foo') self.assertEquals(person.getProperty(property_name, d='foo'), 'foo')
def test_15b_DefaultValueDefinedOnPropertySheet(self, quiet=quiet, def test_15b_DefaultValueDefinedOnPropertySheet(self):
run=run_all_test):
"""Tests that the default value is returned correctly when a default """Tests that the default value is returned correctly when a default
value is defined using the property sheet. value is defined using the property sheet.
""" """
if not run: return
self._addProperty('Person', '''{'id': 'dummy_ps_prop', self._addProperty('Person', '''{'id': 'dummy_ps_prop',
'type': 'string', 'type': 'string',
'mode': 'w', 'mode': 'w',
...@@ -953,10 +920,9 @@ class TestPropertySheet: ...@@ -953,10 +920,9 @@ class TestPropertySheet:
self.assertEquals('foo', self.assertEquals('foo',
person.getDescription('foo')) person.getDescription('foo'))
def test_16_SimpleStringAccessor(self,quiet=quiet, run=run_all_test): def test_16_SimpleStringAccessor(self):
"""Tests a simple string accessor. """Tests a simple string accessor.
This is also a way to test _addProperty method """ This is also a way to test _addProperty method """
if not run: return
self._addProperty('Person', '''{'id': 'dummy_ps_prop', self._addProperty('Person', '''{'id': 'dummy_ps_prop',
'type': 'string', 'type': 'string',
'mode': 'w',}''') 'mode': 'w',}''')
...@@ -1054,11 +1020,10 @@ class TestPropertySheet: ...@@ -1054,11 +1020,10 @@ class TestPropertySheet:
'acquired_property_id': ('title', 'reference'), 'acquired_property_id': ('title', 'reference'),
'mode': 'w', }''' 'mode': 'w', }'''
def test_18_SimpleContentAccessor(self,quiet=quiet, run=run_all_test): def test_18_SimpleContentAccessor(self):
"""Tests a simple content accessor. """Tests a simple content accessor.
This tests content accessors, for properties that have class methods. This tests content accessors, for properties that have class methods.
""" """
if not run: return
# For testing purposes, we add a default_organisation inside a person, # For testing purposes, we add a default_organisation inside a person,
# and we add code to generate a 'default_organisation_title' property on # and we add code to generate a 'default_organisation_title' property on
# this person that will returns the organisation title. # this person that will returns the organisation title.
...@@ -1213,10 +1178,9 @@ class TestPropertySheet: ...@@ -1213,10 +1178,9 @@ class TestPropertySheet:
'acquisition_depends' : None, 'acquisition_depends' : None,
'mode': 'w', }''' 'mode': 'w', }'''
def test_19_AcquiredContentAccessor(self,quiet=quiet, run=run_all_test): def test_19_AcquiredContentAccessor(self):
"""Tests an acquired content accessor. """Tests an acquired content accessor.
""" """
if not run: return
# For testing purposes, we add a default_organisation inside a person, # For testing purposes, we add a default_organisation inside a person,
# and we add code to generate a 'default_organisation_title' property on # and we add code to generate a 'default_organisation_title' property on
# this person that will returns the organisation title. If this is not # this person that will returns the organisation title. If this is not
...@@ -1249,12 +1213,11 @@ class TestPropertySheet: ...@@ -1249,12 +1213,11 @@ class TestPropertySheet:
self.assertEquals(other_pers_title, self.assertEquals(other_pers_title,
other_pers.getDefaultOrganisationTitle()) other_pers.getDefaultOrganisationTitle())
def test_19b_AcquiredContentAccessorWithIdClash(self,quiet=quiet, run=run_all_test): def test_19b_AcquiredContentAccessorWithIdClash(self):
"""Tests a content setters do not set the property on acquired object """Tests a content setters do not set the property on acquired object
that may have the same id, using same scenario as test_19 that may have the same id, using same scenario as test_19
Note that we only test Setter for now. Note that we only test Setter for now.
""" """
if not run: return
self._addProperty('Person', self.DEFAULT_ORGANISATION_TITLE_ACQUIRED_PROP) self._addProperty('Person', self.DEFAULT_ORGANISATION_TITLE_ACQUIRED_PROP)
# add destination base category to Person TI # add destination base category to Person TI
person_ti = self.getTypesTool().getTypeInfo('Person') person_ti = self.getTypesTool().getTypeInfo('Person')
...@@ -1293,12 +1256,11 @@ class TestPropertySheet: ...@@ -1293,12 +1256,11 @@ class TestPropertySheet:
'acquisition_depends' : None, 'acquisition_depends' : None,
'mode': 'rw', }''' 'mode': 'rw', }'''
def test_19c_AcquiredTokensAccessor(self,quiet=quiet, run=run_all_test): def test_19c_AcquiredTokensAccessor(self):
"""Tests an acquired tokens accessor. """Tests an acquired tokens accessor.
We check in particular that getDefault[Property] and We check in particular that getDefault[Property] and
setDefault[Property] are working correctly setDefault[Property] are working correctly
""" """
if not run: return
self._addProperty('Person', self.DEFAULT_LANGUAGE_PROP) self._addProperty('Person', self.DEFAULT_LANGUAGE_PROP)
self._addProperty('Email', self.DEFAULT_LANGUAGE_PROP) self._addProperty('Email', self.DEFAULT_LANGUAGE_PROP)
...@@ -1318,11 +1280,10 @@ class TestPropertySheet: ...@@ -1318,11 +1280,10 @@ class TestPropertySheet:
def test_20_AsContext(self,quiet=quiet, run=run_all_test): def test_20_AsContext(self):
"""asContext method return a temporary copy of an object. """asContext method return a temporary copy of an object.
Any modification made to the copy does not change the original object. Any modification made to the copy does not change the original object.
""" """
if not run: return
obj = self.getPersonModule().newContent(portal_type='Person') obj = self.getPersonModule().newContent(portal_type='Person')
obj.setTitle('obj title') obj.setTitle('obj title')
copy = obj.asContext() copy = obj.asContext()
...@@ -1357,10 +1318,9 @@ class TestPropertySheet: ...@@ -1357,10 +1318,9 @@ class TestPropertySheet:
self.assertEquals(gender.getCategoryRelativeUrl(), new_copy.getGender()) self.assertEquals(gender.getCategoryRelativeUrl(), new_copy.getGender())
self.assertEquals(None, obj.getGender()) self.assertEquals(None, obj.getGender())
def test_21_ActionCondition(self, quiet=quiet, run=run_all_test): def test_21_ActionCondition(self):
"""Tests action conditions """Tests action conditions
""" """
if not run: return
type_tool = self.getTypeTool() type_tool = self.getTypeTool()
portal_type_object = type_tool['Organisation'] portal_type_object = type_tool['Organisation']
def addCustomAction(name,condition): def addCustomAction(name,condition):
...@@ -1467,15 +1427,13 @@ class TestPropertySheet: ...@@ -1467,15 +1427,13 @@ class TestPropertySheet:
# Avoid deletion of actions fo rother tests # Avoid deletion of actions fo rother tests
transaction.abort() transaction.abort()
def test_22_securityReindex(self, quiet=quiet, run=run_all_test): def test_22_securityReindex(self):
""" """
Tests that the security is reindexed when a role is changed on an object. Tests that the security is reindexed when a role is changed on an object.
Note: Turn on Person.acquire_local_roles to 0 in afterSetUp. Note: Turn on Person.acquire_local_roles to 0 in afterSetUp.
""" """
if not run: return portal = self.portal
portal = self.getPortal()
# turn on Person.acquire_local_roles # turn on Person.acquire_local_roles
person = self.getTypesTool().getTypeInfo('Person') person = self.getTypesTool().getTypeInfo('Person')
...@@ -1527,18 +1485,16 @@ class TestPropertySheet: ...@@ -1527,18 +1485,16 @@ class TestPropertySheet:
self.logout() self.logout()
self.login() self.login()
def test_23_titleIsNotDefinedByDefault(self, quiet=quiet, run=run_all_test): def test_23_titleIsNotDefinedByDefault(self):
""" """
Tests that no title attribute is set on new content Tests that no title attribute is set on new content
""" """
if not run: return
portal = self.getPortal()
person_module = self.getPersonModule() person_module = self.getPersonModule()
person = person_module.newContent(portal_type='Person') person = person_module.newContent(portal_type='Person')
self.assertFalse(person.hasTitle()) self.assertFalse(person.hasTitle())
self.assertFalse(person.__dict__.has_key('title')) self.assertFalse(person.__dict__.has_key('title'))
def test_24_relatedValueAccessor(self, quiet=quiet, run=run_all_test): def test_24_relatedValueAccessor(self):
""" """
The purpose of this test is to make sure that category related The purpose of this test is to make sure that category related
accessors work as expected. accessors work as expected.
...@@ -1548,15 +1504,8 @@ class TestPropertySheet: ...@@ -1548,15 +1504,8 @@ class TestPropertySheet:
Test that checked_permission is well configured for View permission Test that checked_permission is well configured for View permission
""" """
if not run: return
if not quiet:
message = 'Test Related Value Accessors'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
# Create a few categories # Create a few categories
region_category = self.getPortal().portal_categories.region region_category = self.portal.portal_categories.region
alpha = region_category.newContent( alpha = region_category.newContent(
portal_type = "Category", portal_type = "Category",
id = "alpha", id = "alpha",
...@@ -1636,7 +1585,7 @@ class TestPropertySheet: ...@@ -1636,7 +1585,7 @@ class TestPropertySheet:
checked_permission="View"), checked_permission="View"),
[doo.getTitle(), bar.getTitle(), ]) [doo.getTitle(), bar.getTitle(), ])
def test_25_AqDynamicWithTempObject(self, quiet=quiet, run=run_all_test): def test_25_AqDynamicWithTempObject(self):
"""Check if _aq_dynamic works correctly, regardless of whether """Check if _aq_dynamic works correctly, regardless of whether
it is first called for a temporary object or a persistent object. it is first called for a temporary object or a persistent object.
...@@ -1646,9 +1595,7 @@ class TestPropertySheet: ...@@ -1646,9 +1595,7 @@ class TestPropertySheet:
such methods from a persistent object may fail, because such a such methods from a persistent object may fail, because such a
persistent object is not an instance of the temporary document class. persistent object is not an instance of the temporary document class.
""" """
if not run: return portal = self.portal
portal = self.getPortal()
# Clear out all generated methods. # Clear out all generated methods.
_aq_reset() _aq_reset()
...@@ -1716,7 +1663,7 @@ class TestPropertySheet: ...@@ -1716,7 +1663,7 @@ class TestPropertySheet:
obj.setFooBar('something') obj.setFooBar('something')
self.assertTrue(obj.hasFooBar()) self.assertTrue(obj.hasFooBar())
def test_27_categoryAccessors(self, quiet=quiet, run=run_all_test): def test_27_categoryAccessors(self):
""" """
The purpose of this test is to make sure that category The purpose of this test is to make sure that category
accessors work as expected. accessors work as expected.
...@@ -1727,13 +1674,6 @@ class TestPropertySheet: ...@@ -1727,13 +1674,6 @@ class TestPropertySheet:
Test that checked_permission is well configured Test that checked_permission is well configured
for View permission for View permission
""" """
if not run: return
if not quiet:
message = 'Test Category Accessors'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
# Create a few categories # Create a few categories
region_category = self.getPortal().portal_categories.region region_category = self.getPortal().portal_categories.region
beta_id = "beta" beta_id = "beta"
...@@ -2335,11 +2275,10 @@ class TestPropertySheet: ...@@ -2335,11 +2275,10 @@ class TestPropertySheet:
self.assertRaises(ValueError, getattr, not_ok, 'attr') self.assertRaises(ValueError, getattr, not_ok, 'attr')
self.assertFalse(hasattr(not_ok, 'attr')) self.assertFalse(hasattr(not_ok, 'attr'))
def test_renameObjectsReindexSubobjects(self, quiet=quiet, run=run_all_test): def test_renameObjectsReindexSubobjects(self):
"""Test that renaming an object with subobjects causes them to be """Test that renaming an object with subobjects causes them to be
reindexed (their path must be updated). reindexed (their path must be updated).
""" """
if not run: return
folder = self.getOrganisationModule() folder = self.getOrganisationModule()
sql_catalog = self.portal.portal_catalog.getSQLCatalog() sql_catalog = self.portal.portal_catalog.getSQLCatalog()
initial_id = 'foo' initial_id = 'foo'
...@@ -2358,24 +2297,22 @@ class TestPropertySheet: ...@@ -2358,24 +2297,22 @@ class TestPropertySheet:
subdocument_record = sql_catalog.getRecordForUid(subdocument.uid) subdocument_record = sql_catalog.getRecordForUid(subdocument.uid)
self.assertEqual(subdocument.getPath(), subdocument_record.path) self.assertEqual(subdocument.getPath(), subdocument_record.path)
def test_getCreationDate(self, quiet=quiet, run=run_all_test): def test_getCreationDate(self):
""" """
Check that getCreationDate does not acquire creation_date property from Check that getCreationDate does not acquire creation_date property from
site. site.
""" """
if not run: return
portal = self.getPortalObject() portal = self.getPortalObject()
folder = self.getOrganisationModule() folder = self.getOrganisationModule()
object = folder.newContent(portal_type='Organisation') object = folder.newContent(portal_type='Organisation')
self.assertNotEquals(object.getCreationDate(), portal.CreationDate()) self.assertNotEquals(object.getCreationDate(), portal.CreationDate())
self.assertNotEquals(object.getCreationDate(), folder.getCreationDate()) self.assertNotEquals(object.getCreationDate(), folder.getCreationDate())
def test_copyWithoutModificationRight(self, quiet=quiet, run=run_all_test): def test_copyWithoutModificationRight(self):
""" """
Check that it is possible to copy an object on which user doesn't have Check that it is possible to copy an object on which user doesn't have
"Modify portal content" permission. "Modify portal content" permission.
""" """
if not run: return
portal = self.getPortalObject() portal = self.getPortalObject()
folder = self.getOrganisationModule() folder = self.getOrganisationModule()
object = folder.newContent(portal_type='Organisation') object = folder.newContent(portal_type='Organisation')
...@@ -2599,7 +2536,7 @@ class TestPropertySheet: ...@@ -2599,7 +2536,7 @@ class TestPropertySheet:
self.assertRaises(TypeError, person.setPropertyList, 'foo_bar', self.assertRaises(TypeError, person.setPropertyList, 'foo_bar',
['a', 'b']) ['a', 'b'])
def testPropertyListOnMonoValuedAcquiredProperty(self,quiet=quiet, run=run_all_test): def testPropertyListOnMonoValuedAcquiredProperty(self):
""" """
Check that we can use setPropertyList and getPropertyList Check that we can use setPropertyList and getPropertyList
on a mono valued acquired property on a mono valued acquired property
......
...@@ -55,16 +55,16 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor): ...@@ -55,16 +55,16 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
Executed before each test_*. Executed before each test_*.
""" """
self.login() self.login()
self.folder = self.getPortal().newContent(id='TestFolder', self.folder = self.portal.newContent(id='TestFolder',
portal_type='Folder') portal_type='Folder')
self.other_folder = self.getPortal().newContent( self.other_folder = self.portal.newContent(
id='OtherTestFolder', portal_type='Folder') id='OtherTestFolder', portal_type='Folder')
def beforeTearDown(self): def beforeTearDown(self):
""" """
Executed after each test_*. Executed after each test_*.
""" """
self.getPortal().manage_delObjects(ids=[self.folder.getId(), self.portal.manage_delObjects(ids=[self.folder.getId(),
self.other_folder.getId()]) self.other_folder.getId()])
clearCache() clearCache()
...@@ -74,27 +74,19 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor): ...@@ -74,27 +74,19 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
""" """
return self.folder.newContent(portal_type='Folder') return self.folder.newContent(portal_type='Folder')
def test_01_folderType(self, quiet=0, run=1): def test_01_folderType(self):
""" """
Test if the present Folder class is the ERP5 version of Folder, not Test if the present Folder class is the ERP5 version of Folder, not
CMF's. CMF's.
""" """
if not run : return
if not quiet:
message = 'Test folderType value'
LOG('Testing... ', 0, message)
self.assertTrue(isinstance(self.getTypesTool()['Folder'], self.assertTrue(isinstance(self.getTypesTool()['Folder'],
ERP5TypeInformation)) ERP5TypeInformation))
def test_02_defaultGenerateNewId(self, quiet=0, run=1): def test_02_defaultGenerateNewId(self):
""" """
Test the default Id generation method. Test the default Id generation method.
Ids are incremented at content creation and start at 1. Ids are incremented at content creation and start at 1.
""" """
if not run : return
if not quiet:
message = 'Test default generateNewId'
LOG('Testing... ', 0, message)
# No id generator defined # No id generator defined
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -103,14 +95,10 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor): ...@@ -103,14 +95,10 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
obj = self.newContent() obj = self.newContent()
self.assertEquals(obj.getId(), '2') self.assertEquals(obj.getId(), '2')
def test_03_customGenerateNewId(self, quiet=0, run=1): def test_03_customGenerateNewId(self):
""" """
Test that id_generator property is honored. Test that id_generator property is honored.
""" """
if not run : return
if not quiet:
message = 'Test custom generateNewId'
LOG('Testing... ', 0, message)
id_generator_script_name = 'testIdGenerator' id_generator_script_name = 'testIdGenerator'
id_generator_id_list = ['first_id', 'second_id'] id_generator_id_list = ['first_id', 'second_id']
createZODBPythonScript(self.getPortal().portal_skins.erp5_core, createZODBPythonScript(self.getPortal().portal_skins.erp5_core,
......
...@@ -32,7 +32,6 @@ import unittest ...@@ -32,7 +32,6 @@ import unittest
import transaction import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.utils import LogInterceptor from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.Cache import clearCache from Products.ERP5Type.Cache import clearCache
...@@ -73,26 +72,18 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -73,26 +72,18 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
""" """
return self.folder.newContent(portal_type='Folder', *args, **kwargs) return self.folder.newContent(portal_type='Folder', *args, **kwargs)
def test_01_folderIsBtree(self, quiet=0, run=1): def test_01_folderIsBtree(self):
""" """
Test the folder is a BTree Test the folder is a BTree
""" """
if not run : return
if not quiet:
message = 'Test folderIsBtree'
LOG('Testing... ', 0, message)
self.assertRaises(NotImplementedError, self.folder.getTreeIdList) self.assertRaises(NotImplementedError, self.folder.getTreeIdList)
self.assertEqual(self.folder.isBTree(), True) self.assertEqual(self.folder.isBTree(), True)
self.assertEqual(self.folder.isHBTree(), False) self.assertEqual(self.folder.isHBTree(), False)
def test_02_migrateFolder(self, quiet=0, run=1): def test_02_migrateFolder(self):
""" """
migrate folder from btree to hbtree migrate folder from btree to hbtree
""" """
if not run : return
if not quiet:
message = 'Test migrateFolder'
LOG('Testing... ', 0, message)
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -116,9 +107,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -116,9 +107,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(self.folder.objectIds()), 3) self.assertEqual(len(self.folder.objectIds()), 3)
# check params of objectIds in case of hbtree # check params of objectIds in case of hbtree
self.assertEqual(len(self.folder.objectIds(base_id=None)), 0) self.assertEqual(len(self.folder.objectIds(base_id=None)), 0)
LOG("test", 300, "rien")
self.assertEqual(len(self.folder.objectValues()), 3) self.assertEqual(len(self.folder.objectValues()), 3)
LOG("test", 300, "base_id")
self.assertEqual(len(self.folder.objectValues(base_id=None)), 0) self.assertEqual(len(self.folder.objectValues(base_id=None)), 0)
# check object ids # check object ids
from DateTime import DateTime from DateTime import DateTime
...@@ -131,39 +120,27 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -131,39 +120,27 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
obj4 = self.newContent() obj4 = self.newContent()
self.assertEquals(obj4.getId().split('-')[0], date) self.assertEquals(obj4.getId().split('-')[0], date)
def test_03_emptyFolderIsBtree(self, quiet=0, run=1): def test_03_emptyFolderIsBtree(self):
""" """
Test the folder is a BTree Test the folder is a BTree
""" """
if not run : return
if not quiet:
message = 'Test EmptyFolderIsBtree'
LOG('Testing... ', 0, message)
self.assertRaises(NotImplementedError, self.folder.getTreeIdList) self.assertRaises(NotImplementedError, self.folder.getTreeIdList)
self.assertEqual(self.folder.isBTree(), True) self.assertEqual(self.folder.isBTree(), True)
self.assertEqual(self.folder.isHBTree(), False) self.assertEqual(self.folder.isHBTree(), False)
def test_03a_filledFolderIsBtree(self, quiet=0, run=1): def test_03a_filledFolderIsBtree(self):
""" """
Test the folder is a BTree Test the folder is a BTree
""" """
if not run : return
if not quiet:
message = 'Test FilledFolderIsBtree'
LOG('Testing... ', 0, message)
self.folder.newContent() self.folder.newContent()
self.assertRaises(NotImplementedError, self.folder.getTreeIdList) self.assertRaises(NotImplementedError, self.folder.getTreeIdList)
self.assertEqual(self.folder.isBTree(), True) self.assertEqual(self.folder.isBTree(), True)
self.assertEqual(self.folder.isHBTree(), False) self.assertEqual(self.folder.isHBTree(), False)
def test_04_migrateEmptyFolder(self, quiet=0, run=1): def test_04_migrateEmptyFolder(self):
""" """
migrate empty folder from btree to hbtree migrate empty folder from btree to hbtree
""" """
if not run : return
if not quiet:
message = 'Test migrateEmptyFolder'
LOG('Testing... ', 0, message)
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -188,11 +165,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -188,11 +165,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(self.folder.isHBTree(), True) self.assertEqual(self.folder.isHBTree(), True)
self.assertEqual(len(self.folder.objectIds()), 1) self.assertEqual(len(self.folder.objectIds()), 1)
def test_05_migrateFolderWithoutIdChange(self, quiet=0, run=1): def test_05_migrateFolderWithoutIdChange(self):
""" """
migrate folder from btree to hbtree, do not touch ids migrate folder from btree to hbtree, do not touch ids
""" """
if not run : return
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -225,11 +201,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -225,11 +201,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
obj4 = self.newContent() obj4 = self.newContent()
self.assertEquals(obj4.getId(), '4') self.assertEquals(obj4.getId(), '4')
def test_06_migrateFolderChangeIdGenerationMethodLater(self, quiet=0, run=1): def test_06_migrateFolderChangeIdGenerationMethodLater(self):
""" """
migrate folder from btree to hbtree, do not touch ids migrate folder from btree to hbtree, do not touch ids
""" """
if not run : return
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -279,14 +254,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -279,14 +254,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
obj5 = self.newContent() obj5 = self.newContent()
self.assertEquals(obj5.getId().split('-')[0], date) self.assertEquals(obj5.getId().split('-')[0], date)
def test_07_migrateFolderTwice(self, quiet=0, run=1): def test_07_migrateFolderTwice(self):
""" """
migrate folder twice from btree to hbtree migrate folder twice from btree to hbtree
""" """
if not run : return
if not quiet:
message = 'Test migrateFolder'
LOG('Testing... ', 0, message)
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -310,9 +281,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -310,9 +281,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(self.folder.objectIds()), 3) self.assertEqual(len(self.folder.objectIds()), 3)
# check params of objectIds in case of hbtree # check params of objectIds in case of hbtree
self.assertEqual(len(self.folder.objectIds(base_id=None)), 0) self.assertEqual(len(self.folder.objectIds(base_id=None)), 0)
LOG("test", 300, "rien")
self.assertEqual(len(self.folder.objectValues()), 3) self.assertEqual(len(self.folder.objectValues()), 3)
LOG("test", 300, "base_id")
self.assertEqual(len(self.folder.objectValues(base_id=None)), 0) self.assertEqual(len(self.folder.objectValues(base_id=None)), 0)
# check object ids # check object ids
from DateTime import DateTime from DateTime import DateTime
...@@ -336,14 +305,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -336,14 +305,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj3.getId(), '%s-3' %date) self.assertEquals(obj3.getId(), '%s-3' %date)
self.assertEquals(obj4.getId().split('-')[0], date) self.assertEquals(obj4.getId().split('-')[0], date)
def test_08_migrateFolderTwiceSimultaneously(self, quiet=0, run=1): def test_08_migrateFolderTwiceSimultaneously(self):
""" """
migrate folder twice from btree to hbtree, simultaneously migrate folder twice from btree to hbtree, simultaneously
""" """
if not run : return
if not quiet:
message = 'Test migrateFolder'
LOG('Testing... ', 0, message)
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -370,9 +335,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -370,9 +335,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(self.folder.objectIds()), 3) self.assertEqual(len(self.folder.objectIds()), 3)
# check params of objectIds in case of hbtree # check params of objectIds in case of hbtree
self.assertEqual(len(self.folder.objectIds(base_id=None)), 0) self.assertEqual(len(self.folder.objectIds(base_id=None)), 0)
LOG("test", 300, "rien")
self.assertEqual(len(self.folder.objectValues()), 3) self.assertEqual(len(self.folder.objectValues()), 3)
LOG("test", 300, "base_id")
self.assertEqual(len(self.folder.objectValues(base_id=None)), 0) self.assertEqual(len(self.folder.objectValues(base_id=None)), 0)
# check object ids # check object ids
from DateTime import DateTime from DateTime import DateTime
...@@ -385,12 +348,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -385,12 +348,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
obj4 = self.newContent() obj4 = self.newContent()
self.assertEquals(obj4.getId().split('-')[0], date) self.assertEquals(obj4.getId().split('-')[0], date)
def test_09_migrateFolderCreateNewObjectAtOnce(self, quiet=0, run=1): def test_09_migrateFolderCreateNewObjectAtOnce(self):
""" """
migrate folder from btree to hbtree, create object with base, without any migrate folder from btree to hbtree, create object with base, without any
previous checks previous checks
""" """
if not run : return
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -414,12 +376,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -414,12 +376,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(self.folder.objectIds(base_id='BASE')), 1) self.assertEqual(len(self.folder.objectIds(base_id='BASE')), 1)
self.assertEqual(len(self.folder.objectValues(base_id='BASE')), 1) self.assertEqual(len(self.folder.objectValues(base_id='BASE')), 1)
def test_10_migrateFolderCreateMoreObjectAtOnceDifferentBase(self, quiet=0, run=1): def test_10_migrateFolderCreateMoreObjectAtOnceDifferentBase(self):
""" """
migrate folder from btree to hbtree, create objects with two bases, migrate folder from btree to hbtree, create objects with two bases,
without any previous checks without any previous checks
""" """
if not run : return
# Create some objects # Create some objects
self.assertEquals(self.folder.getIdGenerator(), '') self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0) self.assertEquals(len(self.folder), 0)
...@@ -447,14 +408,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -447,14 +408,10 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(self.folder.objectIds(base_id='BASE-BELONG')), 1) self.assertEqual(len(self.folder.objectIds(base_id='BASE-BELONG')), 1)
self.assertEqual(len(self.folder.objectValues(base_id='BASE-BELONG')), 1) self.assertEqual(len(self.folder.objectValues(base_id='BASE-BELONG')), 1)
def test_11_folderInMigratedFolderIsBTree(self, quiet=0, run=1): def test_11_folderInMigratedFolderIsBTree(self):
""" """
Test the folder in HBTree folder is a BTree Test the folder in HBTree folder is a BTree
""" """
if not run : return
if not quiet:
message = 'Test folderIsBtree'
LOG('Testing... ', 0, message)
self.folder.migrateToHBTree() self.folder.migrateToHBTree()
transaction.commit() transaction.commit()
self.tic() self.tic()
...@@ -464,16 +421,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -464,16 +421,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(infolder.isBTree(), True) self.assertEqual(infolder.isBTree(), True)
self.assertEqual(infolder.isHBTree(), False) self.assertEqual(infolder.isHBTree(), False)
def test_12_migrateFolderWithGoodIdsInIt(self, quiet=0, run=1): def test_12_migrateFolderWithGoodIdsInIt(self):
""" """
migrate folder from btree to hbtree folder, which already has ids migrate folder from btree to hbtree folder, which already has ids
HBTree-friendly HBTree-friendly
""" """
if not run : return
if not quiet:
message = 'Test migrateFolder'
LOG('Testing... ', 0, message)
id_prefix = 'BASE' id_prefix = 'BASE'
obj1_id = '%s-1'%(id_prefix,) obj1_id = '%s-1'%(id_prefix,)
obj2_id = '%s-2'%(id_prefix,) obj2_id = '%s-2'%(id_prefix,)
...@@ -506,12 +458,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -506,12 +458,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(self.folder.objectValues()), 4) self.assertEqual(len(self.folder.objectValues()), 4)
self.assertEqual(len(self.folder.objectValues(base_id=id_prefix)), 3) self.assertEqual(len(self.folder.objectValues(base_id=id_prefix)), 3)
def test_13_wrongFolderHandlerFix(self, quiet=0, run=1): def test_13_wrongFolderHandlerFix(self):
if not run : return
if not quiet:
message = 'Test migrateFolder'
LOG('Testing... ', 0, message)
self.assertEqual(self.folder.isBTree(), True) self.assertEqual(self.folder.isBTree(), True)
self.assertEqual(self.folder.isHBTree(), False) self.assertEqual(self.folder.isHBTree(), False)
...@@ -535,12 +482,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): ...@@ -535,12 +482,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(self.folder.isBTree(), False) self.assertEqual(self.folder.isBTree(), False)
self.assertEqual(self.folder.isHBTree(), True) self.assertEqual(self.folder.isHBTree(), True)
def test_14_wrongFolderHandlerMigrate(self, quiet=0, run=1): def test_14_wrongFolderHandlerMigrate(self):
if not run : return
if not quiet:
message = 'Test migrateFolder'
LOG('Testing... ', 0, message)
self.assertEqual(self.folder.isBTree(), True) self.assertEqual(self.folder.isBTree(), True)
self.assertEqual(self.folder.isHBTree(), False) self.assertEqual(self.folder.isHBTree(), False)
......
...@@ -28,10 +28,8 @@ ...@@ -28,10 +28,8 @@
import unittest import unittest
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.Tool.SessionTool import SESSION_CACHE_FACTORY from Products.ERP5Type.Tool.SessionTool import SESSION_CACHE_FACTORY
from string import letters as LETTERS from string import letters as LETTERS
...@@ -52,7 +50,6 @@ primitives_kw = dict(attr_1 = ['list_item'], \ ...@@ -52,7 +50,6 @@ primitives_kw = dict(attr_1 = ['list_item'], \
class TestSessionTool(ERP5TypeTestCase): class TestSessionTool(ERP5TypeTestCase):
run_all_test = 1
session_id = "123456789" session_id = "123456789"
def getTitle(self): def getTitle(self):
...@@ -75,7 +72,7 @@ class TestSessionTool(ERP5TypeTestCase): ...@@ -75,7 +72,7 @@ class TestSessionTool(ERP5TypeTestCase):
url_string='127.0.0.1:11211') url_string='127.0.0.1:11211')
self.login() self.login()
def login(self, quiet=0, run=run_all_test): def login(self):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser('ivan', '', ['Manager'], []) uf._doAddUser('ivan', '', ['Manager'], [])
uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], []) uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], [])
...@@ -267,26 +264,12 @@ class TestSessionTool(ERP5TypeTestCase): ...@@ -267,26 +264,12 @@ class TestSessionTool(ERP5TypeTestCase):
session = self.portal.portal_sessions[self.session_id] session = self.portal.portal_sessions[self.session_id]
self.assertEquals(session.get('key'), 'value') self.assertEquals(session.get('key'), 'value')
def test_01_CheckSessionTool(self, quiet=0, run=run_all_test): def test_01_CheckSessionTool(self):
""" Create portal_sessions tool and needed cache factory. """ """ Checks session tool is present """
if not run: self.assertNotEqual(None, getattr(self.portal, 'portal_sessions', None))
return
if not quiet:
message = '\nCheck SessionTool '
ZopeTestCase._print(message)
LOG('Testing... ',0,message)
portal = self.getPortal()
self.assertNotEqual(None, getattr(portal, 'portal_sessions', None))
def test_02_RamSession(self, quiet=0, run=run_all_test):
""" Test RamSession which uses local RAM based cache plugin. """
if not run:
return
if not quiet:
message = '\nTest Ram Session.'
ZopeTestCase._print(message)
LOG('Testing... ', 0, message)
def test_02_RamSession(self):
""" Test RamSession which uses local RAM based cache plugin. """
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = 'stepTestSetGet \ sequence_string = 'stepTestSetGet \
stepTestAcquisitionRamSessionStorage \ stepTestAcquisitionRamSessionStorage \
...@@ -301,15 +284,8 @@ class TestSessionTool(ERP5TypeTestCase): ...@@ -301,15 +284,8 @@ class TestSessionTool(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_03_MemcachedDistributedSession(self, quiet=0, run=run_all_test): def test_03_MemcachedDistributedSession(self):
""" Test DistributedSession which uses memcached based cache plugin. """ """ Test DistributedSession which uses memcached based cache plugin. """
if not run:
return
if not quiet:
message = '\nTest Distributed Session (memcached).'
ZopeTestCase._print(message)
LOG('Testing... ', 0, message)
# create memcached plugin and test # create memcached plugin and test
self._changeCachePlugin('Distributed Ram Cache') self._changeCachePlugin('Distributed Ram Cache')
sequence_list = SequenceList() sequence_list = SequenceList()
......
...@@ -41,8 +41,6 @@ class TestTimerService(ERP5TypeTestCase): ...@@ -41,8 +41,6 @@ class TestTimerService(ERP5TypeTestCase):
idea to put an ERP5-type test in it. idea to put an ERP5-type test in it.
""" """
run_all_test = 1
def getTitle(self): def getTitle(self):
return "TimerService" return "TimerService"
...@@ -51,34 +49,16 @@ class TestTimerService(ERP5TypeTestCase): ...@@ -51,34 +49,16 @@ class TestTimerService(ERP5TypeTestCase):
""" """
return () return ()
def login(self, quiet=0, run=run_all_test): def afterSetUp(self):
uf = self.getPortal().acl_users uf = self.portal.acl_users
uf._doAddUser('rc', '', ['Manager'], []) uf._doAddUser('rc', '', ['Manager'], [])
user = uf.getUserById('rc').__of__(uf) user = uf.getUserById('rc').__of__(uf)
newSecurityManager(None, user) newSecurityManager(None, user)
def enableLightInstall(self): def test_01_checkAnonymousProcessing(self):
"""
You can override this.
Return if we should do a light install (1) or not (0)
"""
return 1
def enableActivityTool(self):
"""
You can override this.
Return if we should create (1) or not (0) an activity tool.
"""
return 1
def afterSetUp(self, quiet=1):
self.login()
def test_01_checkAnonymousProcessing(self, quiet=0, run=run_all_test):
""" """
Test whether a timer can be invoked by anonymous. Test whether a timer can be invoked by anonymous.
""" """
if not run: return
noSecurityManager() noSecurityManager()
timer_service = self.app.Control_Panel.timer_service timer_service = self.app.Control_Panel.timer_service
process_timer = guarded_getattr(timer_service, 'process_timer') process_timer = guarded_getattr(timer_service, 'process_timer')
......
...@@ -28,9 +28,7 @@ ...@@ -28,9 +28,7 @@
import unittest import unittest
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.utils import LogInterceptor from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
...@@ -40,9 +38,6 @@ except ImportError: ...@@ -40,9 +38,6 @@ except ImportError:
pass pass
class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
run_all_test = 1
quiet = 1
# Some helper methods # Some helper methods
def getTitle(self): def getTitle(self):
...@@ -57,16 +52,10 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): ...@@ -57,16 +52,10 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
def test_01_DictInterface(self, quiet=quiet, run=run_all_test): def test_01_DictInterface(self):
"""Check if a transaction variable behaves in the same way as a dict. """Check if a transaction variable behaves in the same way as a dict. """
"""
if not run: return tv = getTransactionalVariable(self.portal)
if not quiet:
message = 'Test Dict Interface'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
tv = getTransactionalVariable(self.getPortal())
self.failIfEqual(tv, None) self.failIfEqual(tv, None)
# Test frequently used dict methods. This does not cover everything, # Test frequently used dict methods. This does not cover everything,
...@@ -89,17 +78,11 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): ...@@ -89,17 +78,11 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
self.failIf('foo' in tv) self.failIf('foo' in tv)
self.failUnlessEqual(len(tv), 1) self.failUnlessEqual(len(tv), 1)
def test_02_Expiration(self, quiet=quiet, run=run_all_test): def test_02_Expiration(self):
"""Check if a transaction variable does not persist over multiple """Check if a transaction variable does not persist over multiple
transactions. transactions.
""" """
if not run: return tv = getTransactionalVariable(self.portal)
if not quiet:
message = 'Test Expiration'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
tv = getTransactionalVariable(self.getPortal())
self.failIfEqual(tv, None) self.failIfEqual(tv, None)
tv.clear() tv.clear()
...@@ -117,17 +100,11 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): ...@@ -117,17 +100,11 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
get_transaction().abort() get_transaction().abort()
self.failIf('toto' in tv) self.failIf('toto' in tv)
def test_03_Durability(self, quiet=quiet, run=run_all_test): def test_03_Durability(self):
"""Check if a transaction variable does not disappear within the same """Check if a transaction variable does not disappear within the same
transaction. transaction.
""" """
if not run: return tv = getTransactionalVariable(self.portal)
if not quiet:
message = 'Test Durability'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
tv = getTransactionalVariable(self.getPortal())
self.failIfEqual(tv, None) self.failIfEqual(tv, None)
tv.clear() tv.clear()
......
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