New test system based on doctest and unittest and many more.
This commit is contained in:
parent
53a945e78c
commit
546caa485d
21 changed files with 312 additions and 144 deletions
27
gen/plone25/mixins/TestMixin.py
Normal file
27
gen/plone25/mixins/TestMixin.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
class TestMixin:
|
||||
'''This class is mixed in with any PloneTestCase.'''
|
||||
def createUser(self, userId, roles):
|
||||
'''Creates a user p_name p_with some p_roles.'''
|
||||
pms = self.portal.portal_membership
|
||||
pms.addMember(userId, 'password', [], [])
|
||||
self.setRoles(roles, name=userId)
|
||||
|
||||
def changeUser(self, userId):
|
||||
'''Logs out currently logged user and logs in p_loginName.'''
|
||||
self.logout()
|
||||
self.login(userId)
|
||||
|
||||
# Functions executed before and after every test -------------------------------
|
||||
def beforeTest(test):
|
||||
g = test.globs
|
||||
g['tool'] = test.app.plone.get('portal_%s' % g['appName'].lower()).appy()
|
||||
g['appFolder'] = g['tool'].o.getProductConfig().diskFolder
|
||||
moduleOrClassName = g['test'].name # Not used yet.
|
||||
# Initialize the test
|
||||
test.createUser('admin', ('Member','Manager'))
|
||||
test.login('admin')
|
||||
g['t'] = g['test']
|
||||
|
||||
def afterTest(test): pass
|
||||
# ------------------------------------------------------------------------------
|
|
@ -1024,7 +1024,8 @@ class AbstractMixin:
|
|||
self._appy_manageRefsFromRequest()
|
||||
# If the creation was initiated by another object, update the
|
||||
# reference.
|
||||
if created:
|
||||
if created and hasattr(self.REQUEST, 'SESSION'):
|
||||
# When used by the test system, no SESSION object is created.
|
||||
session = self.REQUEST.SESSION
|
||||
initiatorUid = session.get('initiator', None)
|
||||
initiator = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue