Commit 012d64a8 authored by Jérome Perrin's avatar Jérome Perrin

get_transaction -> transaction


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26982 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b4719e09
......@@ -29,6 +29,7 @@
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
......@@ -85,12 +86,12 @@ class TestGUISecurity(ERP5TypeTestCase):
asg.setStartDate(DateTime() - 100)
asg.setStopDate(DateTime() + 100)
asg.open()
get_transaction().commit()
transaction.commit()
def stepCreateTestFoo(self, sequence = None, sequence_list = None, **kw):
foo_module = self.getPortal().foo_module
foo_module.newContent(portal_type='Foo', id='foo', foo_category='a')
get_transaction().commit()
transaction.commit()
def stepAccessFoo(self, sequence = None, sequence_list = None, **kw):
"""
......@@ -109,7 +110,7 @@ class TestGUISecurity(ERP5TypeTestCase):
args = (('Manager',), 0)
category.manage_permission('Access contents information', *args)
category.manage_permission('View', *args)
get_transaction().commit()
transaction.commit()
self.tic()
def stepResetCategorySecurity(self, sequence = None, sequence_list = None, **kw):
......@@ -120,7 +121,7 @@ class TestGUISecurity(ERP5TypeTestCase):
args = ((), 1)
category.manage_permission('Access contents information', *args)
category.manage_permission('View', *args)
get_transaction().commit()
transaction.commit()
self.tic()
def test_01_relationFieldToInaccessibleObject(self, quiet=quiet, run=run_all_test):
......
......@@ -29,6 +29,7 @@
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG
......@@ -258,7 +259,7 @@ return []
request.form['my_file_upload'] = FileUpload(DummyFieldStorage())
listbox.get_value('default', render_format='list', REQUEST=request)
try:
get_transaction().commit()
transaction.commit()
except TypeError, e:
self.fail('Unable to commit transaction: %s' % e)
......
......@@ -26,6 +26,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Form.Form import ERP5Form
from DocumentTemplate import String
......@@ -99,7 +100,7 @@ class TestOOoChart(ERP5TypeTestCase, ZopeTestCase.Functional):
wf_id='preference_workflow')
self.validator = Validator()
get_transaction().commit()
transaction.commit()
self.tic()
def createPersons(self):
......
......@@ -28,6 +28,7 @@
import unittest
import transaction
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManagement import getSecurityManager
......@@ -57,7 +58,7 @@ class TestPreferences(ERP5TypeTestCase):
def beforeTearDown(self):
portal_preferences = self.getPreferenceTool()
portal_preferences.manage_delObjects(list(portal_preferences.objectIds()))
get_transaction().commit()
transaction.commit()
self.tic()
def createPreferences(self) :
......@@ -76,7 +77,7 @@ class TestPreferences(ERP5TypeTestCase):
site.setPriority(Priority.SITE)
# commit transaction
get_transaction().commit()
transaction.commit()
self.getPreferenceTool().recursiveReindexObject()
self.tic()
......@@ -299,7 +300,7 @@ class TestPreferences(ERP5TypeTestCase):
id='user_a_1', portal_type='Preference')
user_a_2 = portal_preferences.newContent(
id='user_a_2', portal_type='Preference')
get_transaction().commit(); self.tic()
transaction.commit(); self.tic()
# enable a pref
portal_workflow.doActionFor(
......@@ -314,7 +315,7 @@ class TestPreferences(ERP5TypeTestCase):
user_b_1 = portal_preferences.newContent(
id='user_b_1', portal_type='Preference')
user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 02, 02))
get_transaction().commit(); self.tic()
transaction.commit(); self.tic()
# enable this preference
portal_workflow.doActionFor(
......@@ -338,7 +339,7 @@ class TestPreferences(ERP5TypeTestCase):
id='manager_pref', portal_type='Preference')
manager_pref.setPreferredAccountingTransactionAtDate(
DateTime(2012, 12, 12))
get_transaction().commit(); self.tic()
transaction.commit(); self.tic()
# enable this preference
portal_workflow.doActionFor(
manager_pref, 'enable_action', wf_id='preference_workflow')
......@@ -357,7 +358,7 @@ class TestPreferences(ERP5TypeTestCase):
self.getPortal().portal_workflow.doActionFor(
ptool.site, 'enable_action', wf_id='preference_workflow')
self.assertEquals('global', ptool.site.getPreferenceState())
get_transaction().commit()
transaction.commit()
self.tic()
noSecurityManager()
self.assertEquals(['this_is_visible_by_anonymous'],
......@@ -441,7 +442,7 @@ class TestPreferences(ERP5TypeTestCase):
# enable it and check preference is returned
self.portal.portal_workflow.doActionFor(site_pref, 'enable_action')
self.assertEquals(site_pref.getPreferenceState(), 'global')
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals(['this_is_default'],
preference_tool.getPreferredAccountingTransactionSimulationStateList())
......@@ -457,7 +458,7 @@ class TestPreferences(ERP5TypeTestCase):
# check accessors works
site_pref.setPreferredAccountingTransactionSimulationStateList(
['this_is_system'])
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals(['this_is_system'],
preference_tool.getPreferredAccountingTransactionSimulationStateList())
......@@ -471,7 +472,7 @@ class TestPreferences(ERP5TypeTestCase):
['this_is_user'])
self.portal.portal_workflow.doActionFor(user_pref, 'enable_action')
self.assertEquals(user_pref.getPreferenceState(), 'enabled')
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals(['this_is_user'],
user_pref.getPreferredAccountingTransactionSimulationStateList())
......@@ -481,7 +482,7 @@ class TestPreferences(ERP5TypeTestCase):
# check a user can't edit preference which are marked for manager (only for zope2.8)
try:
from ZODB.Transaction import Transaction
except ImportError:
except ImportError:
self.assertRaises(Unauthorized, user_pref.edit, preferred_ooodoc_server_address="localhost")
......
......@@ -30,6 +30,7 @@ import unittest
from threading import Thread
from thread import get_ident
import transaction
from Testing import ZODButil
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
......@@ -243,7 +244,7 @@ class TestSelectionPersistence(unittest.TestCase):
self.portal_selections = \
self.cnx.root().portal_selections = SelectionTool()
self.portal_selections.setSelectionFor('test_selection', Selection())
get_transaction().commit()
transaction.commit()
def tearDown(self):
# revert the patch from setUp
......@@ -271,13 +272,13 @@ class TestSelectionPersistence(unittest.TestCase):
portal_selections = cnx.root().portal_selections
portal_selections.setSelectionParamsFor(
'test_selection', dict(a="c"))
get_transaction().commit()
transaction.commit()
finally:
cnx.close()
self._runWithAnotherConnection(thread_func)
# This would raise a ConflictError without conflict resolution code
get_transaction().commit()
transaction.commit()
params = self.portal_selections.getSelectionParamsFor('test_selection')
self.assertTrue(params.get('a'))
......@@ -290,13 +291,13 @@ class TestSelectionPersistence(unittest.TestCase):
portal_selections = cnx.root().portal_selections
portal_selections.setSelectionParamsFor(
'test_selection1', dict(a="b"))
get_transaction().commit()
transaction.commit()
finally:
cnx.close()
self._runWithAnotherConnection(thread_func)
# This would raise a ConflictError without conflict resolution code
get_transaction().commit()
transaction.commit()
params = self.portal_selections.getSelectionParamsFor('test_selection1')
self.assertEquals(params.get('a'), 'b')
params = self.portal_selections.getSelectionParamsFor('test_selection2')
......@@ -313,7 +314,7 @@ class TestSelectionPersistence(unittest.TestCase):
# So we make sure that selection container is initialized for this user
self.portal_selections.setSelectionParamsFor(
'test_selection', dict(initialized="1"))
get_transaction().commit()
transaction.commit()
self.portal_selections.setSelectionParamsFor(
'test_selection', dict(a="b"))
......@@ -322,12 +323,12 @@ class TestSelectionPersistence(unittest.TestCase):
portal_selections = cnx.root().portal_selections
portal_selections.setSelectionParamsFor(
'test_selection', dict(a="b"))
get_transaction().commit()
transaction.commit()
finally:
cnx.close()
self._runWithAnotherConnection(thread_func)
get_transaction().commit()
transaction.commit()
# this check is quite low level.
# we know that setUp stored one selection, and each of our 2 threads stored
# one selection.
......@@ -337,7 +338,7 @@ class TestSelectionPersistence(unittest.TestCase):
# test that selection parameters are persistent
self.portal_selections.setSelectionParamsFor(
'test_selection', dict(key="saved_value"))
get_transaction().commit()
transaction.commit()
self.cnx.close()
self.cnx = self.db.open()
......
......@@ -63,7 +63,7 @@ class TestUserManagement(ERP5TypeTestCase):
clearCache(cache_factory_list=('erp5_content_short', ))
self.getPersonModule().manage_delObjects([x for x in
self.getPersonModule().objectIds()])
get_transaction().commit()
transaction.commit()
self.tic()
def login(self):
......@@ -114,7 +114,7 @@ class TestUserManagement(ERP5TypeTestCase):
stop_date=assignment_stop_date,)
if open_assignment:
assignment.open()
get_transaction().commit()
transaction.commit()
self.tic()
return new_person
......@@ -350,7 +350,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
site='subcat',
function='subcat' )
assignment.open()
get_transaction().commit()
transaction.commit()
self.tic()
def beforeTearDown(self):
......@@ -366,7 +366,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
for module in self.portal.objectValues(spec=('ERP5 Folder',)):
module.manage_delObjects([x for x in module.objectIds()])
# commit this
get_transaction().commit()
transaction.commit()
self.tic()
# XXX Isn't it better to clear the cache when deleting a Person ?
clearCache(cache_factory_list=('erp5_content_short', ))
......@@ -475,21 +475,21 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
# getUserByLogin accept login as a string
self.portal.portal_caches.clearAllCache()
get_transaction().commit()
transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin(self.username)
self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference())
# getUserByLogin accept login as a list
self.portal.portal_caches.clearAllCache()
get_transaction().commit()
transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin([self.username])
self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference())
# getUserByLogin accept login as a tuple
self.portal.portal_caches.clearAllCache()
get_transaction().commit()
transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin((self.username,))
self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference())
......@@ -497,7 +497,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
# PreferenceTool pass a user as parameter
user = getSecurityManager().getUser()
self.portal.portal_caches.clearAllCache()
get_transaction().commit()
transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin(user)
self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference())
......@@ -517,7 +517,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
assignment = loginable_person.newContent(portal_type='Assignment',
function='another_subcat')
assignment.open()
get_transaction().commit()
transaction.commit()
self.tic()
person_module_type_information = self.getTypesTool()['Person Module']
......@@ -530,7 +530,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
base_category_script='',
base_category='')
person_module_type_information.updateRoleMapping()
get_transaction().commit()
transaction.commit()
self.tic()
person_module_path = self.getPersonModule().absolute_url(relative=1)
......@@ -547,7 +547,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
self.getOrganisationModule().newContent(portal_type='Organisation',
id='my_company',
title='Nexedi')
get_transaction().commit()
transaction.commit()
self.tic()
response = self.publish('/%s/my_company/getTitle' % self.getOrganisationModule().absolute_url(relative=1),
basic='guest:guest')
......
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