From a8e749b60b415e8e65d82f75a6b39b10e7828be2 Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Fri, 11 Jan 2013 14:36:41 +0100
Subject: [PATCH] Stop using transaction.commit and self.stepTic in unit tests

---
 .../TestTemplateItem/testERP5BearerToken.py            | 10 +---------
 bt5/erp5_bearer_token/bt/revision                      |  2 +-
 .../tests/testDeliveryBuilderToSupportMultipleLines.py |  5 +----
 product/ERP5Security/tests/testERP5Security.py         |  7 ++-----
 4 files changed, 5 insertions(+), 19 deletions(-)

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