Commit 205ccd98 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Migrate test to Live Test.

In Live Test, setUpOnce() is not called, instead afterSetUp() should be
used. Also, remove update of Local Roles as this is already done automatically
upon bt5 installation since a481170a.
parent 3a92d8b6
...@@ -9,12 +9,10 @@ class TestDiscussionThread(SecurityTestCase): ...@@ -9,12 +9,10 @@ class TestDiscussionThread(SecurityTestCase):
def getTitle(self): def getTitle(self):
return "TestDiscussionThread" return "TestDiscussionThread"
def setUpOnce(self): def afterSetUp(self):
""" """
Create users to interact with the discussion forums This is ran before each and every test, used to set up the environment
This is ran only once
""" """
self.portal.portal_types['Person Module'].updateRoleMapping()
user_list = [ user_list = [
# This is Dictator, a user of our portal and a forum admin # This is Dictator, a user of our portal and a forum admin
dict(title='Dictator', reference='admin', function='forum/administrator'), dict(title='Dictator', reference='admin', function='forum/administrator'),
...@@ -31,10 +29,9 @@ class TestDiscussionThread(SecurityTestCase): ...@@ -31,10 +29,9 @@ class TestDiscussionThread(SecurityTestCase):
for user in user_list: for user in user_list:
self.createSimpleUser(**user) self.createSimpleUser(**user)
def afterSetUp(self): self.commit()
""" self.tic()
This is ran before each and every test, used to set up the environment
"""
self.forum_module = self.portal.getDefaultModule(portal_type='Discussion Thread') self.forum_module = self.portal.getDefaultModule(portal_type='Discussion Thread')
self.assertTrue(self.forum_module is not None) self.assertTrue(self.forum_module is not None)
......
2013-09-09 arnaud.fontaine
* ZODB Components: Migrate bt5 test to Live Test.
2013-09-08 arnaud.fontaine 2013-09-08 arnaud.fontaine
* ZODB Components: Revert 'Allow to execute runUnitTest for bt5 Test Components' to fix tests bootstrap. * ZODB Components: Revert 'Allow to execute runUnitTest for bt5 Test Components' to fix tests bootstrap.
......
8 9
\ No newline at end of file \ No newline at end of file
...@@ -99,6 +99,16 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin): ...@@ -99,6 +99,16 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
# pass # pass
# #self.REQUEST.other.pop(key, None) # XXX # #self.REQUEST.other.pop(key, None) # XXX
def createSimpleUser(self, title, reference, *args, **kwargs):
"""
Convenient helper to avoid recreating user every time (in non-Live Test, data
is not kept and usually these users are only created in setUpOnce() (not
used in favor of afterSetUp() in Live Tests)
"""
if not self.portal.acl_users.getUserById(reference):
return super(ERP5TypeLiveTestCase,
self).createSimpleUser(title, reference, *args, **kwargs)
def _close(self): def _close(self):
'''Closes the ZODB connection.''' '''Closes the ZODB connection.'''
revert = transaction.get().__hash__() != self.initial_transaction_hash revert = transaction.get().__hash__() != self.initial_transaction_hash
......
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