Commit a8e749b6 authored by Julien Muchembled's avatar Julien Muchembled

Stop using transaction.commit and self.stepTic in unit tests

parent 448e5168
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import transaction
from DateTime import DateTime from DateTime import DateTime
class TestERP5BearerToken(ERP5TypeTestCase): class TestERP5BearerToken(ERP5TypeTestCase):
...@@ -29,7 +28,6 @@ class TestERP5BearerToken(ERP5TypeTestCase): ...@@ -29,7 +28,6 @@ class TestERP5BearerToken(ERP5TypeTestCase):
person = person_module.newContent(portal_type='Person', person = person_module.newContent(portal_type='Person',
reference='P' + reference) reference='P' + reference)
person.newContent(portal_type = 'Assignment').open() person.newContent(portal_type = 'Assignment').open()
transaction.commit()
self.tic() self.tic()
return person return person
...@@ -39,7 +37,6 @@ class TestERP5BearerToken(ERP5TypeTestCase): ...@@ -39,7 +37,6 @@ class TestERP5BearerToken(ERP5TypeTestCase):
priority=1, priority=1,
preferred_bearer_token_key=self.test_id) preferred_bearer_token_key=self.test_id)
self.preference.enable() self.preference.enable()
transaction.commit()
self.tic() self.tic()
def setupBearerExtraction(self): def setupBearerExtraction(self):
...@@ -53,7 +50,7 @@ class TestERP5BearerToken(ERP5TypeTestCase): ...@@ -53,7 +50,7 @@ class TestERP5BearerToken(ERP5TypeTestCase):
('IExtractionPlugin',)) ('IExtractionPlugin',))
elif len(bearer_extraction_list) > 1: elif len(bearer_extraction_list) > 1:
raise ValueError raise ValueError
transaction.commit() self.commit()
def afterSetUp(self): def afterSetUp(self):
""" """
...@@ -64,12 +61,10 @@ class TestERP5BearerToken(ERP5TypeTestCase): ...@@ -64,12 +61,10 @@ class TestERP5BearerToken(ERP5TypeTestCase):
self.person = self.createPerson(self.test_id) self.person = self.createPerson(self.test_id)
self.setUpBearerTokenKey() self.setUpBearerTokenKey()
self.setupBearerExtraction() self.setupBearerExtraction()
transaction.commit()
self.tic() self.tic()
def beforeTearDown(self): def beforeTearDown(self):
self.portal.portal_preferences.deleteContent(self.preference.getId()) self.portal.portal_preferences.deleteContent(self.preference.getId())
transaction.commit()
self.tic() self.tic()
def test_working_token(self): def test_working_token(self):
...@@ -94,16 +89,13 @@ class TestERP5BearerToken(ERP5TypeTestCase): ...@@ -94,16 +89,13 @@ class TestERP5BearerToken(ERP5TypeTestCase):
def test_no_bearer_token_key(self): def test_no_bearer_token_key(self):
self.preference.edit(preferred_bearer_token_key='') self.preference.edit(preferred_bearer_token_key='')
transaction.commit()
self.tic() self.tic()
transaction.commit()
self.assertRaises(ValueError, self.person.Person_getBearerToken) self.assertRaises(ValueError, self.person.Person_getBearerToken)
def test_changed_bearer_token_key(self): def test_changed_bearer_token_key(self):
token, expiration_time = self.person.Person_getBearerToken() token, expiration_time = self.person.Person_getBearerToken()
self.portal.REQUEST._auth = 'Bearer %s' % token self.portal.REQUEST._auth = 'Bearer %s' % token
self.preference.edit(preferred_bearer_token_key='changed') self.preference.edit(preferred_bearer_token_key='changed')
transaction.commit()
self.tic() self.tic()
reference = self.getTokenCredential(self.portal.REQUEST) reference = self.getTokenCredential(self.portal.REQUEST)
self.assertEqual(reference, None) self.assertEqual(reference, None)
......
10 11
\ No newline at end of file \ No newline at end of file
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
############################################################################## ##############################################################################
import unittest import unittest
import transaction
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
...@@ -345,8 +343,7 @@ class TestNestedLine(TestNestedLineMixin, ERP5TypeTestCase): ...@@ -345,8 +343,7 @@ class TestNestedLine(TestNestedLineMixin, ERP5TypeTestCase):
set priority=200 set priority=200
where uid <> %s where uid <> %s
""" % (table, update_causality_message_uid)) """ % (table, update_causality_message_uid))
transaction.commit() self.tic()
self.stepTic(sequence)
@newSimulationExpectedFailure @newSimulationExpectedFailure
@expectedFailure @expectedFailure
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
""" """
import unittest import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -951,7 +948,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -951,7 +948,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
self.assertTrue(len(person_module.keys())) self.assertTrue(len(person_module.keys()))
# When we update security of a module... # When we update security of a module...
person_module.reindexObjectSecurity() person_module.reindexObjectSecurity()
transaction.commit() self.commit()
# we don't want all underlying objects to be recursively # we don't want all underlying objects to be recursively
# reindexed. After all, its contents do not acquire local roles. # reindexed. After all, its contents do not acquire local roles.
check(['immediateReindexObject']) check(['immediateReindexObject'])
...@@ -963,7 +960,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -963,7 +960,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
for rec in person_module.searchFolder(reference=self.username)] for rec in person_module.searchFolder(reference=self.username)]
self.assertTrue(len(person.objectIds())) self.assertTrue(len(person.objectIds()))
person.reindexObjectSecurity() person.reindexObjectSecurity()
transaction.commit() self.commit()
check(['recursiveImmediateReindexObject']) check(['recursiveImmediateReindexObject'])
self.tic() self.tic()
......
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