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
class CodingStyleTestCase(ERP5TypeTestCase):
"""XXX
"""
run_all_test = 1
quiet = 0
manager_username = 'zope'
manager_password = 'zope'
website_id = 'test'
......@@ -63,24 +61,18 @@ class CodingStyleTestCase(ERP5TypeTestCase):
return self.getBusinessTemplateList()[-1:]
def afterSetUp(self):
portal = self.getPortal()
portal = self.portal
uf = portal.acl_users
uf._doAddUser(self.manager_username, self.manager_password, ['Manager'], [])
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
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
portal_templates = self.getPortal().portal_templates
skin_id_list = []
......@@ -92,7 +84,7 @@ class CodingStyleTestCase(ERP5TypeTestCase):
message_list = []
# Test skins
portal_skins = self.getPortal().portal_skins
portal_skins = self.portal.portal_skins
for skin_id in skin_id_list:
skin = portal_skins[skin_id]
for document in skin.objectValues():
......
......@@ -26,12 +26,10 @@
#
##############################################################################
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.utils import installRealClassTool
from App.config import getConfiguration
from zLOG import LOG
try:
from transaction import get as get_transaction
......@@ -40,49 +38,31 @@ except ImportError:
class TestClassTool(ERP5TypeTestCase):
run_all_test = 1
quiet = 1
def getTitle(self):
return "Class Tool"
def afterSetUp(self):
self.login()
installRealClassTool(self.getPortal())
installRealClassTool(self.portal)
def login(self, quiet=0, run=run_all_test):
uf = self.getPortal().acl_users
def login(self):
uf = self.portal.acl_users
uf._doAddUser('seb', '', ['Manager'], [])
uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], [])
user = uf.getUserById('seb').__of__(uf)
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
"""
if not run:
return
if not quiet:
message = '\nCheck ClassTool '
ZopeTestCase._print(message)
LOG('Testing... ',0,message)
portal = self.getPortal()
portal = self.portal
self.assertNotEqual(None,getattr(portal,'portal_classes',None))
get_transaction().commit()
def test_02_CheckFileWriteIsTransactional(self, quiet=quiet,
run=run_all_test):
if not run:
return
if not quiet:
message = '\nCheck File Transaction'
ZopeTestCase._print(message)
LOG('Testing... ',0,message)
portal = self.getPortal()
def test_02_CheckFileWriteIsTransactional(self):
portal = self.portal
portal_classes = portal.portal_classes
self.assertEqual(portal_classes.getLocalDocumentList(), [],
......
......@@ -29,18 +29,14 @@
import transaction
import unittest
import os
from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
from Products.ERP5Type.tests.Sequence import SequenceList
class TestConstraint(PropertySheetTestCase):
run_all_test = 1
quiet = not os.environ.get('VERBOSE', 0)
object_portal_type = "Organisation"
object_content_portal_type = "Address"
object_title = "Title test"
......@@ -305,11 +301,10 @@ class TestConstraint(PropertySheetTestCase):
id='default_constraint',
description='constraint test')
def test_01_Constraint(self, quiet=quiet, run=run_all_test):
def test_01_Constraint(self):
"""
Test default Constraint class
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint without any configuration
sequence_string = '\
......@@ -319,7 +314,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def stepCreatePropertyExistence0(self, sequence=None,
sequence_list=None, **kw):
......@@ -379,11 +374,10 @@ class TestConstraint(PropertySheetTestCase):
description='propertyExistence test',
title=None)
def test_02_PropertyExistence(self, quiet=quiet, run=run_all_test):
def test_02_PropertyExistence(self):
"""
Test property existence
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint without any configuration
sequence_string = '\
......@@ -460,7 +454,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def stepCreatePropertyTypeValidity(self, sequence=None,
sequence_list=None, **kw):
......@@ -472,11 +466,10 @@ class TestConstraint(PropertySheetTestCase):
id='property_type_validity',
description='propertyTypeValidity test')
def test_03_PropertyTypeValidity(self, quiet=quiet, run=run_all_test):
def test_03_PropertyTypeValidity(self):
"""
Test property type validity
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint without any configuration
sequence_string = '\
......@@ -561,7 +554,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def stepCreateAttributeEquality0(self, sequence=None,
sequence_list=None, **kw):
......@@ -584,11 +577,10 @@ class TestConstraint(PropertySheetTestCase):
description='AttributeEquality test',
title=self.object_title)
def test_04_AttributeEquality(self, quiet=quiet, run=run_all_test):
def test_04_AttributeEquality(self):
"""
Test attribute equality
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint without any configuration
sequence_string = '\
......@@ -627,7 +619,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def stepCreateCategoryExistence0(self, sequence=None,
sequence_list=None, **kw):
......@@ -673,11 +665,10 @@ class TestConstraint(PropertySheetTestCase):
group=None,
portal_type = ('Organisation', ))
def test_05_CategoryExistence(self, quiet=quiet, run=run_all_test):
def test_05_CategoryExistence(self):
"""
Test category existence
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint without any configuration
sequence_string = '\
......@@ -743,7 +734,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def stepCreateCategoryMembershipArity0(self, sequence=None,
sequence_list=None, **kw):
......@@ -815,11 +806,10 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Category', ),
base_category=('group', ))
def test_06_CategoryMembershipArity(self, quiet=quiet, run=run_all_test):
def test_06_CategoryMembershipArity(self):
"""
Test category existence
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint with min=0, max=0
sequence_string = '\
......@@ -966,7 +956,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def test_CategoryMembershipArityNoMax(self):
obj = self._makeOne()
......@@ -1041,11 +1031,10 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Organisation', ),
base_category=('group', ))
def test_07_CategoryRelatedMembershipArity(self, quiet=quiet, run=run_all_test):
def test_07_CategoryRelatedMembershipArity(self):
"""
Test related category existence
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint with min=0, max=0
sequence_string = '\
......@@ -1110,7 +1099,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintFailed \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def test_RelatedCategoryMembershipArityNoMax(self):
related_obj = self._makeOne()
......@@ -1304,12 +1293,10 @@ class TestConstraint(PropertySheetTestCase):
content_object = content_object,
)
def test_ContentExistenceConstraint(self, quiet=quiet, run=run_all_test):
def test_ContentExistenceConstraint(self):
"""
Tests Content Existence
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint without any content
sequence_string = '\
......@@ -1328,7 +1315,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def stepCreateStringAttributeMatch(self, sequence=None, sequence_list=None, **kw):
"""
......@@ -1362,11 +1349,10 @@ class TestConstraint(PropertySheetTestCase):
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()
# Test Constraint with empty Title
sequence_string = '\
......@@ -1396,7 +1382,7 @@ class TestConstraint(PropertySheetTestCase):
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def test_RegisterWithPropertySheet(self):
# constraint are registred in property sheets
......@@ -1522,11 +1508,10 @@ class TestConstraint(PropertySheetTestCase):
condition="object/getTitle")
sequence.set('constraint', constraint)
def test_08_AttributeUnicity(self, quiet=quiet, run=run_all_test):
def test_08_AttributeUnicity(self):
"""
Test attribute unicity
"""
if not run: return
sequence_list = SequenceList()
# Test Constraint without unicity on title
sequence_string = '\
......@@ -1560,7 +1545,7 @@ class TestConstraint(PropertySheetTestCase):
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
......
This diff is collapsed.
......@@ -55,16 +55,16 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
Executed before each test_*.
"""
self.login()
self.folder = self.getPortal().newContent(id='TestFolder',
self.folder = self.portal.newContent(id='TestFolder',
portal_type='Folder')
self.other_folder = self.getPortal().newContent(
self.other_folder = self.portal.newContent(
id='OtherTestFolder', portal_type='Folder')
def beforeTearDown(self):
"""
Executed after each test_*.
"""
self.getPortal().manage_delObjects(ids=[self.folder.getId(),
self.portal.manage_delObjects(ids=[self.folder.getId(),
self.other_folder.getId()])
clearCache()
......@@ -74,27 +74,19 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
"""
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
CMF's.
"""
if not run : return
if not quiet:
message = 'Test folderType value'
LOG('Testing... ', 0, message)
self.assertTrue(isinstance(self.getTypesTool()['Folder'],
ERP5TypeInformation))
def test_02_defaultGenerateNewId(self, quiet=0, run=1):
def test_02_defaultGenerateNewId(self):
"""
Test the default Id generation method.
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
self.assertEquals(self.folder.getIdGenerator(), '')
self.assertEquals(len(self.folder), 0)
......@@ -103,14 +95,10 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
obj = self.newContent()
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.
"""
if not run : return
if not quiet:
message = 'Test custom generateNewId'
LOG('Testing... ', 0, message)
id_generator_script_name = 'testIdGenerator'
id_generator_id_list = ['first_id', 'second_id']
createZODBPythonScript(self.getPortal().portal_skins.erp5_core,
......
......@@ -28,10 +28,8 @@
import unittest
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.Tool.SessionTool import SESSION_CACHE_FACTORY
from string import letters as LETTERS
......@@ -52,7 +50,6 @@ primitives_kw = dict(attr_1 = ['list_item'], \
class TestSessionTool(ERP5TypeTestCase):
run_all_test = 1
session_id = "123456789"
def getTitle(self):
......@@ -75,7 +72,7 @@ class TestSessionTool(ERP5TypeTestCase):
url_string='127.0.0.1:11211')
self.login()
def login(self, quiet=0, run=run_all_test):
def login(self):
uf = self.getPortal().acl_users
uf._doAddUser('ivan', '', ['Manager'], [])
uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], [])
......@@ -267,26 +264,12 @@ class TestSessionTool(ERP5TypeTestCase):
session = self.portal.portal_sessions[self.session_id]
self.assertEquals(session.get('key'), 'value')
def test_01_CheckSessionTool(self, quiet=0, run=run_all_test):
""" Create portal_sessions tool and needed cache factory. """
if not run:
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_01_CheckSessionTool(self):
""" Checks session tool is present """
self.assertNotEqual(None, getattr(self.portal, 'portal_sessions', None))
def test_02_RamSession(self):
""" Test RamSession which uses local RAM based cache plugin. """
sequence_list = SequenceList()
sequence_string = 'stepTestSetGet \
stepTestAcquisitionRamSessionStorage \
......@@ -301,15 +284,8 @@ class TestSessionTool(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string)
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. """
if not run:
return
if not quiet:
message = '\nTest Distributed Session (memcached).'
ZopeTestCase._print(message)
LOG('Testing... ', 0, message)
# create memcached plugin and test
self._changeCachePlugin('Distributed Ram Cache')
sequence_list = SequenceList()
......
......@@ -41,8 +41,6 @@ class TestTimerService(ERP5TypeTestCase):
idea to put an ERP5-type test in it.
"""
run_all_test = 1
def getTitle(self):
return "TimerService"
......@@ -51,34 +49,16 @@ class TestTimerService(ERP5TypeTestCase):
"""
return ()
def login(self, quiet=0, run=run_all_test):
uf = self.getPortal().acl_users
def afterSetUp(self):
uf = self.portal.acl_users
uf._doAddUser('rc', '', ['Manager'], [])
user = uf.getUserById('rc').__of__(uf)
newSecurityManager(None, user)
def enableLightInstall(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):
def test_01_checkAnonymousProcessing(self):
"""
Test whether a timer can be invoked by anonymous.
"""
if not run: return
noSecurityManager()
timer_service = self.app.Control_Panel.timer_service
process_timer = guarded_getattr(timer_service, 'process_timer')
......
......@@ -28,9 +28,7 @@
import unittest
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
......@@ -40,9 +38,6 @@ except ImportError:
pass
class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
run_all_test = 1
quiet = 1
# Some helper methods
def getTitle(self):
......@@ -57,16 +52,10 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
def afterSetUp(self):
self.login()
def test_01_DictInterface(self, quiet=quiet, run=run_all_test):
"""Check if a transaction variable behaves in the same way as a dict.
"""
if not run: return
if not quiet:
message = 'Test Dict Interface'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
def test_01_DictInterface(self):
"""Check if a transaction variable behaves in the same way as a dict. """
tv = getTransactionalVariable(self.getPortal())
tv = getTransactionalVariable(self.portal)
self.failIfEqual(tv, None)
# Test frequently used dict methods. This does not cover everything,
......@@ -89,17 +78,11 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
self.failIf('foo' in tv)
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
transactions.
"""
if not run: return
if not quiet:
message = 'Test Expiration'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
tv = getTransactionalVariable(self.getPortal())
tv = getTransactionalVariable(self.portal)
self.failIfEqual(tv, None)
tv.clear()
......@@ -117,17 +100,11 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
get_transaction().abort()
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
transaction.
"""
if not run: return
if not quiet:
message = 'Test Durability'
ZopeTestCase._print('\n '+message)
LOG('Testing... ', 0, message)
tv = getTransactionalVariable(self.getPortal())
tv = getTransactionalVariable(self.portal)
self.failIfEqual(tv, None)
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