From 16b1573b8f14003bc4b2a64ed92b23f4d01804c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 12 May 2009 12:37:07 +0000 Subject: [PATCH] use transaction module instead of get_transaction git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26926 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/extractMessageCatalog.py | 5 +- product/ERP5/tests/testAccounting.py | 71 +++++----- product/ERP5/tests/testAccountingReports.py | 5 +- product/ERP5/tests/testAccountingRules.py | 4 +- product/ERP5/tests/testAlarm.py | 55 +++---- product/ERP5/tests/testBPMCore.py | 2 +- product/ERP5/tests/testBase.py | 6 +- product/ERP5/tests/testBug.py | 5 +- product/ERP5/tests/testBusinessTemplate.py | 6 +- product/ERP5/tests/testCRM.py | 80 ++++++----- product/ERP5/tests/testCalendar.py | 44 +++--- .../tests/testContributionRegistryTool.py | 16 +-- .../ERP5/tests/testConversionInSimulation.py | 69 ++++----- product/ERP5/tests/testCrmReports.py | 31 ++-- product/ERP5/tests/testDomainTool.py | 44 +++--- product/ERP5/tests/testERP5Base.py | 10 +- product/ERP5/tests/testERP5Budget.py | 5 +- product/ERP5/tests/testERP5Category.py | 7 +- product/ERP5/tests/testERP5Core.py | 21 +-- .../tests/testERP5CurrencyExchangeLine.py | 19 +-- product/ERP5/tests/testERP5Web.py | 78 +++++----- product/ERP5/tests/testERP5WebWithDms.py | 31 ++-- product/ERP5/tests/testICal.py | 29 ++-- product/ERP5/tests/testIdTool.py | 7 +- product/ERP5/tests/testImmobilisation.py | 41 +++--- product/ERP5/tests/testInteractionWorkflow.py | 5 +- product/ERP5/tests/testInventory.py | 12 +- product/ERP5/tests/testInventoryAPI.py | 27 ++-- product/ERP5/tests/testInvoice.py | 134 +++++++++--------- product/ERP5/tests/testInvoiceVAT.py | 31 ++-- .../tests/testNotificationMessageModule.py | 13 +- product/ERP5/tests/testNotificationTool.py | 11 +- product/ERP5/tests/testOpenOrder.py | 30 ++-- product/ERP5/tests/testOrder.py | 35 ++--- product/ERP5/tests/testOrderBuilder.py | 3 +- product/ERP5/tests/testPackingList.py | 6 +- product/ERP5/tests/testPasswordTool.py | 6 +- product/ERP5/tests/testProductionOrder.py | 4 +- product/ERP5/tests/testQueryModule.py | 7 +- product/ERP5/tests/testRSS.py | 7 +- product/ERP5/tests/testResource.py | 26 ++-- product/ERP5/tests/testResourceVariation.py | 7 +- product/ERP5/tests/testRule.py | 74 +++++----- product/ERP5/tests/testSupply.py | 9 +- product/ERP5/tests/testTemplate.py | 23 +-- product/ERP5/tests/testTradeCondition.py | 49 +++---- product/ERP5/tests/testTradeReports.py | 13 +- product/ERP5/tests/testTransformation.py | 3 +- product/ERP5/tests/testWorklist.py | 19 +-- product/ERP5/tests/testXHTML.py | 5 - 50 files changed, 635 insertions(+), 615 deletions(-) diff --git a/product/ERP5/tests/extractMessageCatalog.py b/product/ERP5/tests/extractMessageCatalog.py index 4508aa99b9..58b9a0a563 100644 --- a/product/ERP5/tests/extractMessageCatalog.py +++ b/product/ERP5/tests/extractMessageCatalog.py @@ -38,10 +38,7 @@ then erp5_content.pot and erp5_ui.pot will be made in the current directory. """ import unittest -try: - from transaction import get as get_transaction -except ImportError: - pass +import transaction # we reuse TestXHTML test. from Products.ERP5.tests.testXHTML import TestXHTML diff --git a/product/ERP5/tests/testAccounting.py b/product/ERP5/tests/testAccounting.py index ee8efae0c1..58f8c90705 100644 --- a/product/ERP5/tests/testAccounting.py +++ b/product/ERP5/tests/testAccounting.py @@ -33,6 +33,7 @@ import unittest import os +import transaction from DateTime import DateTime from Products.CMFCore.utils import _checkPermission @@ -191,7 +192,7 @@ class AccountingTestCase(ERP5TypeTestCase): self.validateRules() # and all this available to catalog - get_transaction().commit() + transaction.commit() self.tic() @@ -200,7 +201,7 @@ class AccountingTestCase(ERP5TypeTestCase): """ if os.environ.get('erp5_save_data_fs'): return - get_transaction().abort() + transaction.abort() self.accounting_module.manage_delObjects( list(self.accounting_module.objectIds())) organisation_list = ('my_organisation', 'client_1', 'client_2', 'supplier') @@ -224,7 +225,7 @@ class AccountingTestCase(ERP5TypeTestCase): and x.getPriority() != Priority.SITE]) self.portal.portal_simulation.manage_delObjects(list( self.portal.portal_simulation.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() ERP5TypeTestCase.tearDown(self) @@ -299,7 +300,7 @@ class TestTransactionValidation(AccountingTestCase): start_date=DateTime('2007/01/01'), stop_date=DateTime('2007/12/31')) accounting_period_2007.start() - get_transaction().commit() + transaction.commit() self.tic() def test_SaleInvoiceTransactionValidationDate(self): @@ -806,12 +807,12 @@ class TestClosingPeriod(AccountingTestCase): """Various tests for closing the period. """ def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # we manually remove the content of stock table, because unindexObject # might not work correctly on Balance Transaction, and we don't want # leave something in stock table that will change the next test. self.portal.erp5_sql_connection.manage_test('truncate stock') - get_transaction().commit() + transaction.commit() def test_createBalanceOnNode(self): period = self.section.newContent(portal_type='Accounting Period') @@ -995,7 +996,7 @@ class TestClosingPeriod(AccountingTestCase): self.assertEquals(None, pl_movement.getDestinationTotalAssetPrice()) self.assertEquals(None, pl_movement.getSourceTotalAssetPrice()) self.assertEquals(300., pl_movement.getDestinationDebit()) - get_transaction().commit() + transaction.commit() self.tic() def test_createBalanceOnPayment(self): @@ -1242,7 +1243,7 @@ class TestClosingPeriod(AccountingTestCase): pl_movement.getDestinationDebit(), accounting_currency_precision) - get_transaction().commit() + transaction.commit() self.tic() # now check content of stock table @@ -1312,7 +1313,7 @@ class TestClosingPeriod(AccountingTestCase): dict(source_value=self.account_module.receivable, source_asset_credit=2.2, source_credit=200))) - get_transaction().commit() + transaction.commit() self.tic() period.AccountingPeriod_createBalanceTransaction( @@ -1374,7 +1375,7 @@ class TestClosingPeriod(AccountingTestCase): self.assertEquals(None, dollar_movement.getSourceTotalAssetPrice()) self.assertEquals(200, dollar_movement.getDestinationCredit()) - get_transaction().commit() + transaction.commit() self.tic() # now check content of stock table @@ -1450,7 +1451,7 @@ class TestClosingPeriod(AccountingTestCase): period, 'deliver_action', profit_and_loss_account=pl_account.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('delivered', period.getSimulationState()) @@ -1694,7 +1695,7 @@ class TestClosingPeriod(AccountingTestCase): destination_value=self.account_module.stocks, destination_credit=90,) balance.stop() - get_transaction().commit() + transaction.commit() self.tic() stool = self.portal.portal_simulation @@ -1733,7 +1734,7 @@ class TestClosingPeriod(AccountingTestCase): destination_debit=30,) balance.stop() - get_transaction().commit() + transaction.commit() self.tic() stool = self.portal.portal_simulation @@ -1770,7 +1771,7 @@ class TestClosingPeriod(AccountingTestCase): destination_value=self.account_module.payable, destination_credit=100,) balance.stop() - get_transaction().commit() + transaction.commit() self.tic() stool = self.portal.portal_simulation @@ -1827,7 +1828,7 @@ class TestClosingPeriod(AccountingTestCase): destination_credit=100,) balance.stop() balance.deliver() - get_transaction().commit() + transaction.commit() self.tic() stool = self.portal.portal_simulation @@ -1852,11 +1853,11 @@ class TestClosingPeriod(AccountingTestCase): source_debit=50), dict(source_value=self.account_module.receivable, source_credit=50))) - get_transaction().commit() + transaction.commit() self.tic() # let's try to reindex and check if values are still OK balance.reindexObject() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(-150, stool.getInventory( @@ -1880,7 +1881,7 @@ class TestClosingPeriod(AccountingTestCase): destination_value=self.account_module.receivable, destination_debit=100,) balance.stop() - get_transaction().commit() + transaction.commit() self.tic() stool = self.portal.portal_simulation @@ -1918,7 +1919,7 @@ class TestClosingPeriod(AccountingTestCase): destination_value=self.account_module.receivable, destination_debit=100,) balance.stop() - get_transaction().commit() + transaction.commit() self.tic() stool = self.portal.portal_simulation @@ -2179,7 +2180,7 @@ class TestTransactions(AccountingTestCase): self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action') self.assertEquals('stopped', accounting_transaction.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() payment = invoice.Invoice_createRelatedPaymentTransaction( @@ -2210,7 +2211,7 @@ class TestTransactions(AccountingTestCase): self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action') self.assertEquals('stopped', accounting_transaction.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() payment = invoice.Invoice_createRelatedPaymentTransaction( @@ -2247,7 +2248,7 @@ class TestTransactions(AccountingTestCase): source_debit=20),)) other_accounting_transaction.cancel() - get_transaction().commit() + transaction.commit() self.tic() payment = invoice.Invoice_createRelatedPaymentTransaction( @@ -2383,7 +2384,7 @@ class TestTransactions(AccountingTestCase): # when restarting, grouping is removed invoice.restart() - get_transaction().commit() + transaction.commit() self.tic() self.failIf(invoice_line.getGroupingReference()) self.failIf(payment_line.getGroupingReference()) @@ -2490,7 +2491,7 @@ class TestTransactions(AccountingTestCase): self.failUnless(payment_line.getGroupingReference()) invoice.cancel() - get_transaction().commit() + transaction.commit() self.tic() self.failIf(invoice_line.getGroupingReference()) self.failIf(payment_line.getGroupingReference()) @@ -2662,10 +2663,10 @@ class TestAccountingWithSequences(AccountingTestCase): """Cleanup for next test. All tests uses the same accounts and same entities, so we just cleanup accounting module and simulation. """ - get_transaction().abort() + transaction.abort() for folder in (self.accounting_module, self.portal.portal_simulation): folder.manage_delObjects([i for i in folder.objectIds()]) - get_transaction().commit() + transaction.commit() self.tic() def login(self) : @@ -2727,7 +2728,7 @@ class TestAccountingWithSequences(AccountingTestCase): for entity in (self.client, self.vendor, self.other_vendor): entity.setRegion(self.default_region) self.getWorkflowTool().doActionFor(entity, 'validate_action') - get_transaction().commit() + transaction.commit() self.tic() def stepCreateEntities(self, sequence, **kw) : @@ -2816,7 +2817,7 @@ class TestAccountingWithSequences(AccountingTestCase): self.YEN = currency_module.newContent( portal_type = self.currency_portal_type, reference = "YEN", id = "YEN" ) - get_transaction().commit() + transaction.commit() self.tic() else: self.EUR = currency_module.EUR @@ -2883,7 +2884,7 @@ class TestAccountingWithSequences(AccountingTestCase): account.validate() self.failUnless('Site Error' not in account.view()) self.assertEquals(account.getValidationState(), 'validated') - get_transaction().commit() + transaction.commit() self.tic() def stepCreateAccounts(self, sequence, **kw) : @@ -3241,7 +3242,7 @@ class TestAccountingWithSequences(AccountingTestCase): self.failUnless(receivable.getSource() != None) self.failUnless(receivable.getDestination() != None) if reindex: - get_transaction().commit() + transaction.commit() self.tic() if check_consistency: self.failUnless(len(transaction.checkConsistency()) == 0, @@ -3791,7 +3792,7 @@ class TestAccountingTransactionTemplate(AccountingTestCase): preference.priority = Priority.USER preference.enable() - get_transaction().commit() + transaction.commit() self.tic() document = self.accounting_module.newContent( @@ -3799,7 +3800,7 @@ class TestAccountingTransactionTemplate(AccountingTestCase): document.edit(title='My Accounting Transaction') document.Base_makeTemplateFromDocument(form_id=None) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(preference.objectIds()), 1) @@ -3810,7 +3811,7 @@ class TestAccountingTransactionTemplate(AccountingTestCase): self.accounting_module.manage_delObjects(ids=[document.getId()]) - get_transaction().commit() + transaction.commit() self.tic() template = preference.objectValues()[0] @@ -3822,7 +3823,7 @@ class TestAccountingTransactionTemplate(AccountingTestCase): new_document = self.accounting_module[new_document_id] new_document.makeTemplateInstance() - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(new_document.getTitle(), 'My Accounting Transaction') @@ -3836,7 +3837,7 @@ class TestAccountingTransactionTemplate(AccountingTestCase): preference.priority = Priority.USER preference.enable() - get_transaction().commit() + transaction.commit() self.tic() document = self.accounting_module.newContent( diff --git a/product/ERP5/tests/testAccountingReports.py b/product/ERP5/tests/testAccountingReports.py index afd5e7ec97..f9b045c65a 100644 --- a/product/ERP5/tests/testAccountingReports.py +++ b/product/ERP5/tests/testAccountingReports.py @@ -31,6 +31,7 @@ import unittest +import transaction from DateTime import DateTime from Products.ERP5.tests.testAccounting import AccountingTestCase @@ -57,7 +58,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase): # workaround the fact that Balance Transaction Line are not unindexed # correctly when removed self.portal.erp5_sql_connection.manage_test('TRUNCATE TABLE stock') - get_transaction().commit() + transaction.commit() def testJournal(self): # Journal report. @@ -922,7 +923,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase): source_credit=400.0))) t4.stop() t4.deliver() - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render diff --git a/product/ERP5/tests/testAccountingRules.py b/product/ERP5/tests/testAccountingRules.py index cd3e343d5f..69dbc84c08 100644 --- a/product/ERP5/tests/testAccountingRules.py +++ b/product/ERP5/tests/testAccountingRules.py @@ -44,6 +44,8 @@ import unittest import os import random +import transaction + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.Sequence import Sequence, SequenceList @@ -208,7 +210,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): invoice_transaction_rule.deleteContent( [x for x in invoice_transaction_rule.objectIds()]) self.assertEquals(len(invoice_transaction_rule.objectValues()), 0) - get_transaction().commit() + transaction.commit() # and add new content, predicate product_line predicate_product_notebook = invoice_transaction_rule.newContent( diff --git a/product/ERP5/tests/testAlarm.py b/product/ERP5/tests/testAlarm.py index 3f5b9f762b..b6f18471b7 100644 --- a/product/ERP5/tests/testAlarm.py +++ b/product/ERP5/tests/testAlarm.py @@ -27,6 +27,7 @@ ############################################################################## import unittest +import transaction from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -99,7 +100,7 @@ class TestAlarm(ERP5TypeTestCase): ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) alarm = self.newAlarm() - get_transaction().commit() + transaction.commit() self.tic() now = DateTime() date = addToDate(now,day=1) @@ -119,7 +120,7 @@ class TestAlarm(ERP5TypeTestCase): date = addToDate(now,day=2) alarm.setPeriodicityStartDate(date) alarm.setPeriodicityHourFrequency(1) - get_transaction().commit() + transaction.commit() self.tic() alarm.setNextAlarmDate(current_date=now) self.assertEquals(alarm.getAlarmDate(),date) @@ -147,7 +148,7 @@ class TestAlarm(ERP5TypeTestCase): date = addToDate(now,day=2) alarm.setPeriodicityStartDate(date) alarm.setPeriodicityHourFrequency(3) - get_transaction().commit() + transaction.commit() self.tic() alarm.setNextAlarmDate(current_date=now) self.assertEquals(alarm.getAlarmDate(),date) @@ -178,7 +179,7 @@ class TestAlarm(ERP5TypeTestCase): hour_list = (6,10,15,21) alarm.setPeriodicityStartDate(now) alarm.setPeriodicityHourList(hour_list) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(alarm.getAlarmDate(),right_first_date) alarm.setNextAlarmDate(current_date=right_first_date) @@ -203,7 +204,7 @@ class TestAlarm(ERP5TypeTestCase): alarm.setPeriodicityStartDate(now) alarm.setPeriodicityDayFrequency(1) alarm.setPeriodicityHourList((10,)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(alarm.getAlarmDate(),right_first_date) alarm.setNextAlarmDate(current_date=right_first_date) @@ -227,7 +228,7 @@ class TestAlarm(ERP5TypeTestCase): alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityDayFrequency(3) alarm.setPeriodicityHourList((14,15,17)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(alarm.getAlarmDate(),right_first_date) alarm.setNextAlarmDate(current_date=right_first_date) @@ -254,7 +255,7 @@ class TestAlarm(ERP5TypeTestCase): alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityDayFrequency(4) alarm.setPeriodicityHourList((14,15,17)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(alarm.getAlarmDate(),right_first_date) alarm.setNextAlarmDate(current_date=right_first_date) @@ -280,7 +281,7 @@ class TestAlarm(ERP5TypeTestCase): right_fourth_date = DateTime(self.date_format % (2006,10,2,6,00,00)) right_fifth_date = DateTime(self.date_format % (2006,10,2,15,00,00)) alarm = self.newAlarm() - get_transaction().commit() + transaction.commit() self.tic() alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityWeekDayList(('Monday','Friday')) @@ -313,7 +314,7 @@ class TestAlarm(ERP5TypeTestCase): alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityMonthDayList((1,15)) alarm.setPeriodicityHourList((12,14)) - get_transaction().commit() + transaction.commit() self.tic() self.checkDate(alarm, right_first_date, right_second_date, right_third_date, right_fourth_date) @@ -333,7 +334,7 @@ class TestAlarm(ERP5TypeTestCase): alarm.setPeriodicityMonthDayList((1,)) alarm.setPeriodicityMonthFrequency(2) alarm.setPeriodicityHourList((6,)) - get_transaction().commit() + transaction.commit() self.tic() self.checkDate(alarm, right_first_date, right_second_date, right_third_date) @@ -352,7 +353,7 @@ class TestAlarm(ERP5TypeTestCase): alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityHourList((6,)) alarm.setPeriodicityWeekList((41,43)) - get_transaction().commit() + transaction.commit() self.tic() self.checkDate(alarm, right_first_date, right_second_date, right_third_date,right_fourth_date) @@ -369,7 +370,7 @@ class TestAlarm(ERP5TypeTestCase): date = addToDate(now,day=2) alarm.setPeriodicityStartDate(date) alarm.setPeriodicityMinuteFrequency(5) - get_transaction().commit() + transaction.commit() self.tic() alarm.setNextAlarmDate(current_date=now) self.assertEquals(alarm.getAlarmDate(),date) @@ -395,7 +396,7 @@ class TestAlarm(ERP5TypeTestCase): date = addToDate(now,hour=2) alarm.setPeriodicityStartDate(now) alarm.setPeriodicityMinuteFrequency(1) - get_transaction().commit() + transaction.commit() self.tic() alarm.setNextAlarmDate(current_date=date) self.assertEquals(alarm.getAlarmDate(),date) @@ -410,7 +411,7 @@ class TestAlarm(ERP5TypeTestCase): active_process = alarm.newActiveProcess() self.assertEquals('Active Process', active_process.getPortalType()) self.assertEquals(alarm, active_process.getCausalityValue()) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(active_process, alarm.getLastActiveProcess()) @@ -429,13 +430,13 @@ class TestAlarm(ERP5TypeTestCase): skin_folder[sense_method_id].ZPythonScript_edit('*args,**kw', 'raise Exception') del skin_folder alarm = self.newAlarm() - get_transaction().commit() + transaction.commit() self.tic() now = DateTime() alarm.setActiveSenseMethodId(sense_method_id) self.assertEquals(alarm.isActive(), 0) alarm.activeSense() - get_transaction().commit() + transaction.commit() try: self.tic() except RuntimeError: @@ -449,7 +450,7 @@ class TestAlarm(ERP5TypeTestCase): # Make the sense method succeed and leave a trace self.getPortal().portal_skins[skin_folder_id][sense_method_id].ZPythonScript_edit('*args,**kw', 'context.newActiveProcess()') alarm.activeSense() - get_transaction().commit() + transaction.commit() # Note: this call to tic will fail, because the previous message is still there # This behaviour is logical if we consider that we want to keep errors # in order to know that an error occured. @@ -474,19 +475,19 @@ class TestAlarm(ERP5TypeTestCase): ZopeTestCase._print('\n%s ' % message) LOG('Testing... ', 0, message) alarm = self.newAlarm() - get_transaction().commit() + transaction.commit() self.tic() now = DateTime() date = addToDate(now, day=1) alarm.setPeriodicityStartDate(date) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(alarm.getAlarmDate(), date) # This should not do change the alarm date alarm.setNextAlarmDate(current_date=now) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(alarm.getAlarmDate(), date) @@ -494,7 +495,7 @@ class TestAlarm(ERP5TypeTestCase): a_tool = self.getAlarmTool() alarm_uid = alarm.getUid() a_tool.manage_delObjects(uids=[alarm_uid]) - get_transaction().commit() + transaction.commit() self.tic() # Check that related entry was removed sql_connection = self.getSQLConnection() @@ -513,7 +514,7 @@ class TestAlarm(ERP5TypeTestCase): LOG('Testing... ', 0, message) alarm = self.newAlarm() alarm.setEnabled(True) - get_transaction().commit() + transaction.commit() self.tic() sense_method_id = 'Alarm_testSenseMethodForTic' @@ -526,7 +527,7 @@ class TestAlarm(ERP5TypeTestCase): 'context.setDescription("a")') del skin_folder alarm.setActiveSenseMethodId(sense_method_id) - get_transaction().commit() + transaction.commit() self.tic() alarm_tool = self.getPortal().portal_alarms # Nothing should happens yet @@ -536,7 +537,7 @@ class TestAlarm(ERP5TypeTestCase): date = addToDate(now, day=1) alarm.setPeriodicityStartDate(date) alarm.setPeriodicityMinuteFrequency(1) - get_transaction().commit() + transaction.commit() self.tic() alarm_tool.tic() self.assertEquals(alarm.getDescription(), 'a') @@ -564,10 +565,10 @@ class TestAlarm(ERP5TypeTestCase): alarm.edit(alarm_notification_mode="always", active_sense_method_id=sense_method_id, enabled=True) - get_transaction().commit() + transaction.commit() self.tic() alarm.activeSense() - get_transaction().commit() + transaction.commit() messages_list = self.getActivityTool().getMessageList() self.assertEquals(2, len(messages_list)) # check tags after activeSense @@ -580,7 +581,7 @@ class TestAlarm(ERP5TypeTestCase): raise AssertionError, m.method_id # execute alarm sense script and check tags self.getActivityTool().manageInvoke(alarm.getPhysicalPath(),sense_method_id) - get_transaction().commit() + transaction.commit() messages_list = self.getActivityTool().getMessageList() for m in messages_list: if m.method_id == 'notify': diff --git a/product/ERP5/tests/testBPMCore.py b/product/ERP5/tests/testBPMCore.py index 796b084ef8..9eb3ecde4d 100644 --- a/product/ERP5/tests/testBPMCore.py +++ b/product/ERP5/tests/testBPMCore.py @@ -274,7 +274,7 @@ class TestBPMMixin(ERP5TypeTestCase): int_index=3, membership_criterion_base_category='resource_use', membership_criterion_category='resource_use/use/normal') - get_transaction().commit() + transaction.commit() self.tic() accounting_rule_cell_list = itr.contentValues( portal_type='Accounting Rule Cell') diff --git a/product/ERP5/tests/testBase.py b/product/ERP5/tests/testBase.py index d3efbb72fe..7d5d2dfa2f 100644 --- a/product/ERP5/tests/testBase.py +++ b/product/ERP5/tests/testBase.py @@ -30,6 +30,8 @@ import unittest import os +import transaction + from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager @@ -169,7 +171,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): Check if there is a activity in activity queue. """ portal = self.getPortal() - get_transaction().commit() + transaction.commit() message_list = portal.portal_activities.getMessageList() method_id_list = [x.method_id for x in message_list] # XXX FIXME: how many activities should be created normally ? @@ -1046,7 +1048,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): """ self.getPortal().person_module.newContent(portal_type='Person', title='translate_table_test') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(1, len(self.getPortal().portal_catalog( portal_type='Person', title='translate_table_test'))) diff --git a/product/ERP5/tests/testBug.py b/product/ERP5/tests/testBug.py index e177010aab..a255de50d9 100644 --- a/product/ERP5/tests/testBug.py +++ b/product/ERP5/tests/testBug.py @@ -29,6 +29,7 @@ import unittest +import transaction from DateTime import DateTime from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.Sequence import SequenceList @@ -118,7 +119,7 @@ class TestBug(ERP5TypeTestCase): start_date='1980-01-01', stop_date='2099-12-31') assignment.open() - get_transaction().commit() + transaction.commit() self.tic() module_list = [] portal_type_list = [] @@ -136,7 +137,7 @@ class TestBug(ERP5TypeTestCase): '') ti.updateRoleMapping() - get_transaction().commit() + transaction.commit() self.tic() portal.portal_caches.clearAllCache() diff --git a/product/ERP5/tests/testBusinessTemplate.py b/product/ERP5/tests/testBusinessTemplate.py index d7afe83a41..00e3e2d44a 100644 --- a/product/ERP5/tests/testBusinessTemplate.py +++ b/product/ERP5/tests/testBusinessTemplate.py @@ -28,6 +28,8 @@ import unittest +import transaction + from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager @@ -87,7 +89,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): if (content_type_registry is not None and 'any' in content_type_registry.predicate_ids): content_type_registry.removePredicate('any') - get_transaction().commit() + transaction.commit() def beforeTearDown(self): """Remove objects created tests.""" @@ -121,7 +123,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): for business_template in self.getTemplateTool().contentValues(): if business_template.getTitle() == 'geek template': self.getTemplateTool().manage_delObjects([business_template.getId()]) - get_transaction().commit() + transaction.commit() self._ignore_log_errors() def login(self): diff --git a/product/ERP5/tests/testCRM.py b/product/ERP5/tests/testCRM.py index c0991c5587..02f82ec245 100644 --- a/product/ERP5/tests/testCRM.py +++ b/product/ERP5/tests/testCRM.py @@ -30,6 +30,8 @@ import os import email import email.Header +import transaction + from Products.CMFCore.WorkflowCore import WorkflowException from Products.ERP5Type.tests.utils import DummyMailHost from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -65,7 +67,7 @@ class TestCRM(ERP5TypeTestCase): self.assertEqual(len(event.getCausalityRelatedValueList()), 0) - get_transaction().commit() + transaction.commit() self.tic() portal_workflow.doActionFor(event, 'create_related_event_action', @@ -73,7 +75,7 @@ class TestCRM(ERP5TypeTestCase): related_event_title='New Title', related_event_description='New Desc') - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(event.getCausalityRelatedValueList()), 1) @@ -145,7 +147,7 @@ class TestCRM(ERP5TypeTestCase): 'person_module_selection', []) self.portal.portal_selections.setSelectionParamsFor( 'person_module_selection', dict(title='Pers1')) - get_transaction().commit() + transaction.commit() self.tic() person_module.PersonModule_newEvent(portal_type='Mail Message', title='The Event Title', @@ -156,7 +158,7 @@ class TestCRM(ERP5TypeTestCase): text_content='Event Content', form_id='PersonModule_viewPersonList') - get_transaction().commit() + transaction.commit() self.tic() related_event = pers1.getDestinationRelatedValue( @@ -180,7 +182,7 @@ class TestCRM(ERP5TypeTestCase): self.portal.portal_selections.setSelectionCheckedUidsFor( 'person_module_selection', [pers1.getUid(), pers2.getUid()]) - get_transaction().commit() + transaction.commit() self.tic() person_module.PersonModule_newEvent(portal_type='Mail Message', title='The Event Title', @@ -191,7 +193,7 @@ class TestCRM(ERP5TypeTestCase): text_content='Event Content', form_id='PersonModule_viewPersonList') - get_transaction().commit() + transaction.commit() self.tic() for person in (pers1, pers2): @@ -262,12 +264,12 @@ class TestCRM(ERP5TypeTestCase): ticket_url = ticket.getRelativeUrl() event = self.portal.event_module.newContent(portal_type=portal_type, follow_up=ticket_url) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(event.getCausalityRelatedValueList()), 0) event.receive() portal_workflow.doActionFor(event, 'acknowledge_action', create_event=0) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(event.getCausalityRelatedValueList()), 0) @@ -278,12 +280,12 @@ class TestCRM(ERP5TypeTestCase): ticket_url = ticket.getRelativeUrl() event = self.portal.event_module.newContent(portal_type=portal_type, follow_up=ticket_url) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(event.getCausalityRelatedValueList()), 0) event.receive() portal_workflow.doActionFor(event, 'acknowledge_action', create_event=1) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(event.getCausalityRelatedValueList()), 1) new_event = event.getCausalityRelatedValue() @@ -300,14 +302,14 @@ class TestCRM(ERP5TypeTestCase): title='Event Title', text_content='Event Content', text_format='text/plain') - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(event.getCausalityRelatedValueList()), 0) event.receive() portal_workflow.doActionFor(event, 'acknowledge_action', create_event=1, quote_original_message=1) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(event.getCausalityRelatedValueList()), 1) new_event = event.getCausalityRelatedValue() @@ -360,16 +362,16 @@ class TestCRMMailIngestion(ERP5TypeTestCase): default_email_text='he@erp5.org') # make sure customers are available to catalog - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary for module in (self.portal.event_module, self.portal.campaign_module): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def _readTestData(self, filename): @@ -417,14 +419,14 @@ class TestCRMMailIngestion(ERP5TypeTestCase): # source is found automatically, based on the From: header in the mail event = self._ingestMail('simple') # metadata discovery is done in an activity - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('person_module/sender', event.getSource()) def test_recipient(self): # destination is found automatically, based on the To: header in the mail event = self._ingestMail('simple') - get_transaction().commit() + transaction.commit() self.tic() destination_list = event.getDestinationList() destination_list.sort() @@ -437,10 +439,10 @@ class TestCRMMailIngestion(ERP5TypeTestCase): # But, we don't want it to associate with the first campaign simply # because we searched against nothing self.portal.campaign_module.newContent(portal_type='Campaign') - get_transaction().commit() + transaction.commit() self.tic() event = self._ingestMail('simple') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(None, event.getFollowUp()) @@ -515,7 +517,7 @@ class TestCRMMailIngestion(ERP5TypeTestCase): """ document = self._ingestMail(filename='forwarded') - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(document.getContentInformation().get('From'), 'Me <me@erp5.org>') @@ -531,7 +533,7 @@ class TestCRMMailIngestion(ERP5TypeTestCase): """ document = self._ingestMail(filename='forwarded_attached') - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(document.getContentInformation().get('From'), 'Me <me@erp5.org>') @@ -542,7 +544,7 @@ class TestCRMMailIngestion(ERP5TypeTestCase): def test_encoding(self): document = self._ingestMail(filename='encoded') - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(document.getContentInformation().get('To'), @@ -615,16 +617,16 @@ class TestCRMMailSend(ERP5TypeTestCase): self.portal._setObject('MailHost', DummyMailHost('MailHost')) # make sure customers are available to catalog - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary for module in (self.portal.event_module, self.portal.campaign_module,): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def test_MailFromMailMessageEvent(self): @@ -637,7 +639,7 @@ class TestCRMMailSend(ERP5TypeTestCase): event.setTextContent('Mail Content') self.portal.portal_workflow.doActionFor(event, 'start_action', send_mail=1) - get_transaction().commit() + transaction.commit() self.tic() last_message = self.portal.MailHost._last_message self.assertNotEquals((), last_message) @@ -666,7 +668,7 @@ class TestCRMMailSend(ERP5TypeTestCase): event.setTextContent('Mail Content') self.portal.portal_workflow.doActionFor(event, 'start_action', send_mail=1) - get_transaction().commit() + transaction.commit() self.tic() last_message_1, last_message_2 = self.portal.MailHost._message_list[-2:] self.assertNotEquals((), last_message_1) @@ -691,7 +693,7 @@ class TestCRMMailSend(ERP5TypeTestCase): event.setTextContent('Mail Content') self.portal.portal_workflow.doActionFor(event, 'start_action', send_mail=1) - get_transaction().commit() + transaction.commit() self.tic() # no mail sent last_message = self.portal.MailHost._last_message @@ -708,7 +710,7 @@ class TestCRMMailSend(ERP5TypeTestCase): self.portal.portal_workflow.doActionFor(event, 'start_action', send_mail=1) - get_transaction().commit() + transaction.commit() self.tic() # this means no message have been set self.assertEquals((), self.portal.MailHost._last_message) @@ -724,7 +726,7 @@ class TestCRMMailSend(ERP5TypeTestCase): self.portal.portal_workflow.doActionFor(event, 'receive_action') self.portal.portal_workflow.doActionFor(event, 'mark_started_action') - get_transaction().commit() + transaction.commit() self.tic() # this means no message have been set self.assertEquals((), self.portal.MailHost._last_message) @@ -740,7 +742,7 @@ class TestCRMMailSend(ERP5TypeTestCase): event.setTextContent('Hello<br/>World') self.portal.portal_workflow.doActionFor(event, 'start_action', send_mail=1) - get_transaction().commit() + transaction.commit() self.tic() last_message = self.portal.MailHost._last_message self.assertNotEquals((), last_message) @@ -765,7 +767,7 @@ class TestCRMMailSend(ERP5TypeTestCase): event.setTextContent('Hà hà ') self.portal.portal_workflow.doActionFor(event, 'start_action', send_mail=1) - get_transaction().commit() + transaction.commit() self.tic() last_message = self.portal.MailHost._last_message self.assertNotEquals((), last_message) @@ -799,7 +801,7 @@ class TestCRMMailSend(ERP5TypeTestCase): document_pdf = add_document('sample_attachment.pdf', '1', self.portal.document_module, 'PDF') - get_transaction().commit() + transaction.commit() self.tic() # Add a ticket @@ -855,7 +857,7 @@ class TestCRMMailSend(ERP5TypeTestCase): document_odt = add_document('sample_attachment.odt', '2', self.portal.document_module, 'Text') - get_transaction().commit() + transaction.commit() self.tic() # Add a ticket @@ -911,7 +913,7 @@ class TestCRMMailSend(ERP5TypeTestCase): document_zip = add_document('sample_attachment.zip', '3', self.portal.document_module, 'File') - get_transaction().commit() + transaction.commit() self.tic() # Add a ticket @@ -967,7 +969,7 @@ class TestCRMMailSend(ERP5TypeTestCase): document_gif = add_document('sample_attachment.gif', '4', self.portal.image_module, 'Image') - get_transaction().commit() + transaction.commit() self.tic() # Add a ticket @@ -1018,7 +1020,7 @@ class TestCRMMailSend(ERP5TypeTestCase): document_html.edit(text_content='<html><body>Hello world!</body></html>', reference='sample_attachment.html') - get_transaction().commit() + transaction.commit() self.tic() # Add a ticket @@ -1119,7 +1121,7 @@ class TestCRMMailSend(ERP5TypeTestCase): document_txt = add_document('sample_attachment.txt', '2', self.portal.person_module['me'], 'File') - get_transaction().commit() + transaction.commit() self.tic() # Add a ticket @@ -1177,7 +1179,7 @@ class TestCRMMailSend(ERP5TypeTestCase): document_gif = add_document('sample_attachment.gif', '1', self.portal.person_module['me'], 'Image') - get_transaction().commit() + transaction.commit() self.tic() # Add a ticket diff --git a/product/ERP5/tests/testCalendar.py b/product/ERP5/tests/testCalendar.py index f73c166071..5dd6445efc 100644 --- a/product/ERP5/tests/testCalendar.py +++ b/product/ERP5/tests/testCalendar.py @@ -26,6 +26,8 @@ # ############################################################################## +import transaction + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase from Products.ERP5Type.Base import _aq_reset from AccessControl.SecurityManagement import newSecurityManager, \ @@ -102,12 +104,12 @@ class TestCalendar(ERP5ReportTestCase): self._addPropertySheet('Group Presence Period', 'CalendarPeriodConstraint') def beforeTearDown(self): - get_transaction().abort() + transaction.abort() for module in (self.portal.group_calendar_module, self.portal.leave_request_module, self.portal.presence_request_module,): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def _addPropertySheet(self, type_info_name, property_sheet_name): @@ -823,7 +825,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() # there is 43200 seconds between self.start_date and self.stop_date @@ -858,7 +860,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(0, person.getAvailableTime( @@ -897,7 +899,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((18 - 14 + 12 - 8) * 60 * 60, person.getAvailableTime( @@ -931,7 +933,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(0, person.getAvailableTime( @@ -968,7 +970,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() # 2008/01/07 was a Monday @@ -1003,7 +1005,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(0, person.getAvailableTime( @@ -1034,7 +1036,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((18 - 8) * 60 * 60, person.getAvailableTime( @@ -1067,7 +1069,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((9-8 + 18-17) * 60 * 60, person.getAvailableTime( @@ -1106,7 +1108,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() leave_request = self.portal.leave_request_module.newContent( portal_type='Leave Request') @@ -1119,7 +1121,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((18-9) * 60 * 60, person.getAvailableTime( @@ -1155,7 +1157,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() leave_request = self.portal.leave_request_module.newContent( portal_type='Leave Request') @@ -1168,7 +1170,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((17-8) * 60 * 60, person.getAvailableTime( @@ -1204,7 +1206,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() leave_request = self.portal.leave_request_module.newContent( portal_type='Leave Request') @@ -1223,7 +1225,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((18-13 + 12-10 + 9-8) * 60 * 60, person.getAvailableTime( @@ -1263,7 +1265,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() leave_request = self.portal.leave_request_module.newContent( portal_type='Leave Request') @@ -1282,7 +1284,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((18-11 + 9-8) * 60 * 60, person.getAvailableTime( @@ -1320,7 +1322,7 @@ class TestCalendar(ERP5ReportTestCase): person = self.portal.person_module.newContent(portal_type='Person') assignment = person.newContent(portal_type='Assignment', calendar_value=group_calendar) - get_transaction().commit() + transaction.commit() self.tic() leave_request = self.portal.leave_request_module.newContent( portal_type='Leave Request') @@ -1339,7 +1341,7 @@ class TestCalendar(ERP5ReportTestCase): leave_request.setDestinationValue(person) leave_request.confirm() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals((18-11 + 9-8) * 60 * 60, person.getAvailableTime( @@ -1423,7 +1425,7 @@ class TestCalendar(ERP5ReportTestCase): self.portal.portal_categories.calendar_period_type.type3) leave_request2.confirm() - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render diff --git a/product/ERP5/tests/testContributionRegistryTool.py b/product/ERP5/tests/testContributionRegistryTool.py index 64a0aabe8d..06a57b087b 100644 --- a/product/ERP5/tests/testContributionRegistryTool.py +++ b/product/ERP5/tests/testContributionRegistryTool.py @@ -28,11 +28,7 @@ import unittest from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase -try: - from transaction import get_transaction -except ImportError: - pass - +import transaction class TestContributionRegistryTool(ERP5TypeTestCase): @@ -74,7 +70,7 @@ return predicate.getDestinationPortalType() """) self.portal.manage_addProduct['PythonScripts'].manage_addPythonScript(id='IngestionFile_testEvent') self.portal.IngestionFile_testEvent.write(python_script_src) - get_transaction().commit() + transaction.commit() self.tic() def setUpMimeType(self): @@ -84,7 +80,7 @@ return predicate.getDestinationPortalType() id='mime_type') text = mime_type.newContent(portal_type='Category', id='text') text.newContent(portal_type='Category', id='html') - get_transaction().commit() + transaction.commit() self.tic() if getattr(portal_categories, 'mime_type', None) is None: @@ -92,7 +88,7 @@ return predicate.getDestinationPortalType() id='mime_type') message = mime_type.newContent(portal_type='Category', id='message') message.newContent(portal_type='Category', id='rfc822') - get_transaction().commit() + transaction.commit() self.tic() def setUpPredicate(self): @@ -104,7 +100,7 @@ return predicate.getDestinationPortalType() predicate._setMembershipCriterionCategoryList(['mime_type/text/html']) predicate._setMembershipCriterionBaseCategoryList(['mime_type']) predicate.setDestinationPortalType('Web Page') - get_transaction().commit() + transaction.commit() self.tic() if getattr(portal_contribution_registry, 'my_predicate', None) is None: @@ -116,7 +112,7 @@ return predicate.getDestinationPortalType() predicate.setCriterion('file_extension', identity=['eml']) predicate.setDestinationPortalType('Mail Message') predicate.setTestMethodId('IngestionFile_testEvent') - get_transaction().commit() + transaction.commit() self.tic() def testFindPortalTypeName(self, quiet=0, run=run_all_test): diff --git a/product/ERP5/tests/testConversionInSimulation.py b/product/ERP5/tests/testConversionInSimulation.py index 9c7134b59c..5edb12f265 100644 --- a/product/ERP5/tests/testConversionInSimulation.py +++ b/product/ERP5/tests/testConversionInSimulation.py @@ -25,8 +25,11 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## + import unittest import os + +import transaction from DateTime import DateTime from zLOG import LOG from Products.CMFCore.utils import _checkPermission @@ -144,7 +147,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): self.login() def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary currency_list = ('euro', 'yen', 'usd') module = self.portal.currency_module @@ -156,7 +159,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): currency.manage_delObjects([x.getId() for x in currency.objectValues( portal_type='Currency Exchange Line')]) - get_transaction().commit() + transaction.commit() self.tic() def login(self,name=username, quiet=0, run=run_all_test): @@ -203,7 +206,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): invoice_rule = portal.portal_rules.default_invoice_transaction_rule invoice_rule.deleteContent([x.getId() for x in invoice_rule.objectValues()]) - get_transaction().commit() + transaction.commit() self.tic() region_predicate = invoice_rule.newContent(portal_type = 'Predicate') product_line_predicate = invoice_rule.newContent(portal_type = 'Predicate') @@ -238,7 +241,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): destination_value=account_module[line_destination_id]) invoice_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() def test_01_simulation_movement_destination_asset_price(self,quiet=0, @@ -264,7 +267,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction x_curr_ex_line = currency.newContent( portal_type='Currency Exchange Line', @@ -275,7 +278,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): x_curr_ex_line.setStopDate(DateTime(2008,10,22)) x_curr_ex_line.validate() self.createInvoiceTransactionRule(currency) - get_transaction().commit() + transaction.commit() self.tic()#execute transactio client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -301,7 +304,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule = order.getCausalityRelatedValue( @@ -356,7 +359,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction x_curr_ex_line = currency.newContent( portal_type='Currency Exchange Line', @@ -367,7 +370,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): x_curr_ex_line.setStopDate(DateTime(2008,10,22)) x_curr_ex_line.validate() self.createInvoiceTransactionRule(currency) - get_transaction().commit() + transaction.commit() self.tic()#execute transactio client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -393,7 +396,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule = order.getCausalityRelatedValue( @@ -441,7 +444,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction x_curr_ex_line = currency.newContent( portal_type='Currency Exchange Line', @@ -452,7 +455,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): x_curr_ex_line.setStopDate(DateTime(2008,10,22)) x_curr_ex_line.validate() self.createInvoiceTransactionRule(currency) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -477,14 +480,14 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): quantity=1, price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type='Sale Packing List') self.assertNotEquals(related_packing_list, None) related_packing_list.start() related_packing_list.stop() - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule = order.getCausalityRelatedValue( portal_type='Applied Rule') @@ -493,7 +496,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): portal_type='Sale Invoice Transaction') self.assertNotEquals(related_invoice, None) related_invoice.start() - get_transaction().commit() + transaction.commit() self.tic() line_list= related_invoice.contentValues( portal_type=self.portal.getPortalAccountingMovementTypeList()) @@ -531,7 +534,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction x_curr_ex_line = currency.newContent( portal_type='Currency Exchange Line', @@ -542,7 +545,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): x_curr_ex_line.setStopDate(DateTime(2008,10,22)) x_curr_ex_line.validate() self.createInvoiceTransactionRule(currency) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -567,7 +570,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): quantity=5, price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type='Sale Packing List') @@ -579,16 +582,16 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): round(655.957*related_packing_list_line.getTotalPrice()) related_packing_list_line.edit(quantity=3.0) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(related_packing_list.getCausalityState(), 'diverged') self._solveDivergence(related_packing_list, 'quantity', 'accept') - get_transaction().commit() + transaction.commit() self.tic() related_packing_list.start() related_packing_list.stop() - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule = order.getCausalityRelatedValue( @@ -631,7 +634,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction x_curr_ex_line = currency.newContent( portal_type='Currency Exchange Line', @@ -642,7 +645,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): x_curr_ex_line.setStopDate(DateTime(2008,10,22)) x_curr_ex_line.validate() self.createInvoiceTransactionRule(currency) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -667,7 +670,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): quantity=5, price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type='Purchase Packing List') @@ -679,17 +682,17 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): round(655.957*related_packing_list_line.getTotalPrice()) related_packing_list_line.edit(quantity=3.0) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(related_packing_list.getCausalityState(), 'diverged') self._solveDivergence(related_packing_list, 'quantity','accept') - get_transaction().commit() + transaction.commit() self.tic() related_packing_list.start() related_packing_list.stop() - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule = order.getCausalityRelatedValue( @@ -731,7 +734,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction x_curr_ex_line = currency.newContent( portal_type='Currency Exchange Line', @@ -742,7 +745,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): x_curr_ex_line.setStopDate(DateTime(2008,10,22)) x_curr_ex_line.validate() self.createInvoiceTransactionRule(currency) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -769,7 +772,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): quantity=5, price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type='Sale Packing List') @@ -780,7 +783,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): order.getIncoterm()) related_packing_list.start() related_packing_list.stop() - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_packing_list.getCausalityRelatedValue( portal_type='Sale Invoice Transaction') @@ -810,7 +813,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): portal_type='Currency', title='euro') currency.setBaseUnitQuantity(0.01) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -844,7 +847,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase): quantity=1.5, price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type='Sale Packing List') diff --git a/product/ERP5/tests/testCrmReports.py b/product/ERP5/tests/testCrmReports.py index 512e0f2f6e..ffec367648 100644 --- a/product/ERP5/tests/testCrmReports.py +++ b/product/ERP5/tests/testCrmReports.py @@ -31,10 +31,13 @@ """Tests Standards ERP5 Crm Reports """ import unittest + +import transaction +from DateTime import DateTime + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase from Products.ERP5Type.tests.utils import reindex from AccessControl.SecurityManagement import newSecurityManager -from DateTime import DateTime class CrmTestCase(ERP5ReportTestCase): """Tests starts with a preference activated for self.my_organisation, logged in @@ -226,14 +229,14 @@ class CrmTestCase(ERP5ReportTestCase): doc.validate() # and all this available to catalog - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): """Remove all documents. """ - get_transaction().abort() + transaction.abort() self.campaign_module.manage_delObjects( list(self.campaign_module.objectIds())) self.meeting_module.manage_delObjects( @@ -250,7 +253,7 @@ class CrmTestCase(ERP5ReportTestCase): self.event_module.manage_delObjects( list(self.event_module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def getBusinessTemplateList(self): @@ -366,7 +369,7 @@ class TestCrmReports(CrmTestCase): causality=eventOut1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() request_form = self.portal.REQUEST.other request_form['from_date'] = DateTime(2007, 1, 1) @@ -513,7 +516,7 @@ class TestCrmReports(CrmTestCase): causality=second_event_out1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -677,7 +680,7 @@ class TestCrmReports(CrmTestCase): causality=eventOut1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -823,7 +826,7 @@ class TestCrmReports(CrmTestCase): causality=second_event_out1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -987,7 +990,7 @@ class TestCrmReports(CrmTestCase): causality=second_event_inc1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -1133,7 +1136,7 @@ class TestCrmReports(CrmTestCase): causality=second_event_inc1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -1297,7 +1300,7 @@ class TestCrmReports(CrmTestCase): causality=eventOut1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -1443,7 +1446,7 @@ class TestCrmReports(CrmTestCase): causality=second_event_out1.getRelativeUrl(), follow_up=second.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -1702,7 +1705,7 @@ class TestCrmReports(CrmTestCase): causality=event6.getRelativeUrl(), follow_up=campaign.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other @@ -2045,7 +2048,7 @@ class TestCrmReports(CrmTestCase): causality=event6.getRelativeUrl(), follow_up=campaign.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # set request variables and render request_form = self.portal.REQUEST.other diff --git a/product/ERP5/tests/testDomainTool.py b/product/ERP5/tests/testDomainTool.py index 0225ce57ce..a242345ced 100644 --- a/product/ERP5/tests/testDomainTool.py +++ b/product/ERP5/tests/testDomainTool.py @@ -28,6 +28,8 @@ import unittest +import transaction + from Products.ERP5.tests.testPredicate import TestPredicateMixIn, REGION_FRANCE_PATH, REGION_GERMANY_PATH, GROUP_STOREVER_PATH, GROUP_OTHER_PATH from DateTime import DateTime from AccessControl.SecurityManagement import newSecurityManager @@ -115,7 +117,7 @@ class TestDomainTool(TestPredicateMixIn): if not 'asia' in portal_categories[bc].objectIds(): big_region = portal_categories[bc].newContent(id='asia',portal_type='Category') - get_transaction().commit() + transaction.commit() self.tic() def checkPredicate(self, test=None): @@ -145,7 +147,7 @@ class TestDomainTool(TestPredicateMixIn): # Test with order line not none and predicate to none order_line.setQuantity(45) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test, portal_type=rule_query) @@ -155,13 +157,13 @@ class TestDomainTool(TestPredicateMixIn): order_line.setQuantity(45) kw = {'portal_type':'Mapped Value'} predicate.setCriterion('quantity',identity=45,min=None,max=None) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),1) order_line.setQuantity(40) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) @@ -170,13 +172,13 @@ class TestDomainTool(TestPredicateMixIn): order_line.setQuantity(45) predicate = self.getPredicate() predicate.setCriterion('quantity',identity=None,min=30,max=None) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),1) order_line.setQuantity(10) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test, portal_type=rule_query) @@ -186,13 +188,13 @@ class TestDomainTool(TestPredicateMixIn): order_line.setQuantity(45) predicate = self.getPredicate() predicate.setCriterion('quantity',identity=None,min=None,max=50) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),1) order_line.setQuantity(60) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) @@ -201,20 +203,20 @@ class TestDomainTool(TestPredicateMixIn): order_line.setQuantity(20) predicate = self.getPredicate() predicate.setCriterion('quantity',identity=None,min=30,max=50) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) order_line.setQuantity(60) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) order_line.setQuantity(45) predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(len(predicate_list),1) @@ -222,25 +224,25 @@ class TestDomainTool(TestPredicateMixIn): # and also predicate to a category predicate.setMembershipCriterionBaseCategoryList(['region']) predicate.setMembershipCriterionCategoryList(['region/europe']) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) order_line.setCategoryList(['region/africa']) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) order_line.setCategoryList(['region/europe']) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),1) order_line.setQuantity(60) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) @@ -259,14 +261,14 @@ class TestDomainTool(TestPredicateMixIn): self.supply_line.setStartDateRangeMax(date2) current_date = DateTime('2005/04/1 10:47:26.388 GMT-4') order_line.setStartDate(current_date) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),0) current_date = DateTime('2005/04/09 10:47:26.388 GMT-4') order_line.setStartDate(current_date) - get_transaction().commit() + transaction.commit() self.tic() predicate_list = domain_tool.searchPredicateList(order_line,test=test,**kw) self.assertEquals(len(predicate_list),1) @@ -297,7 +299,7 @@ class TestDomainTool(TestPredicateMixIn): #self.supply_line.setMultimembershipCriterionBaseCategoryList(['resource']) self.supply_line.setMappedValuePropertyList(['base_price','priced_quantity']) #self.supply_line.setMembershipCriterionCategoryList(['resource/%s' % self.resource.getRelativeUrl()]) - get_transaction().commit() + transaction.commit() self.tic() domain_tool = self.getDomainTool() context = self.resource.asContext(categories=['resource/%s' % self.resource.getRelativeUrl()]) @@ -319,7 +321,7 @@ class TestDomainTool(TestPredicateMixIn): LOG('Test04, supply_line.getStartDateRangeMin',0,self.supply_line.getStartDateRangeMin()) LOG('Test04, supply_line.getStartDateRangeMax',0,self.supply_line.getStartDateRangeMax()) self.supply_line.setMappedValuePropertyList(['base_price','priced_quantity']) - get_transaction().commit() + transaction.commit() self.tic() domain_tool = self.getDomainTool() order_line = self.getOrderLine() @@ -380,7 +382,7 @@ class TestDomainTool(TestPredicateMixIn): hasCellContent = getattr(x, 'hasCellContent', None) return bool(hasCellContent and hasCellContent(base_id='path')) - get_transaction().commit() + transaction.commit() self.tic() domain_tool = self.getDomainTool() context = self.resource.asContext( @@ -419,7 +421,7 @@ class TestDomainTool(TestPredicateMixIn): membership_criterion_category_list=[GROUP_STOREVER_PATH, REGION_GERMANY_PATH]) document = self.createDocument(group='nexedi/storever', region='europe/western_europe/france') - get_transaction().commit() + transaction.commit() self.tic() portal_domains = self.getPortalObject().portal_domains # Basic sanity checks diff --git a/product/ERP5/tests/testERP5Base.py b/product/ERP5/tests/testERP5Base.py index 39319c73b4..3bef905625 100644 --- a/product/ERP5/tests/testERP5Base.py +++ b/product/ERP5/tests/testERP5Base.py @@ -537,7 +537,7 @@ class TestERP5Base(ERP5TypeTestCase): self.assertEquals(person.getCareerFunctionTitle(), function_title) self.assertEquals(person.getCareerFunctionValue(), function_object) # function must be acquired on person - person.reindexObject(); get_transaction().commit(); self.tic() + person.reindexObject(); transaction.commit(); self.tic() self.failUnless(person in function_object.getFunctionRelatedValueList()) # Set & Check role @@ -550,7 +550,7 @@ class TestERP5Base(ERP5TypeTestCase): self.assertEquals(person.getCareerRoleTitle(), role_title) self.assertEquals(person.getCareerRoleValue(), role_object) # role must be acquired on person - person.reindexObject(); get_transaction().commit(); self.tic() + person.reindexObject(); transaction.commit(); self.tic() self.failUnless(person in role_object.getRoleRelatedValueList()) # Set & Check grade @@ -563,7 +563,7 @@ class TestERP5Base(ERP5TypeTestCase): self.assertEquals(person.getCareerGradeTitle(), grade_title) self.assertEquals(person.getCareerGradeValue(), grade_object) # grade must be acquired on person - person.reindexObject(); get_transaction().commit(); self.tic() + person.reindexObject(); transaction.commit(); self.tic() self.failUnless(person in grade_object.getGradeRelatedValueList()) # Set & Check salary level @@ -578,7 +578,7 @@ class TestERP5Base(ERP5TypeTestCase): self.assertEquals(person.getCareerSalaryLevelTitle(), salary_level_title) self.assertEquals(person.getCareerSalaryLevelValue(), salary_level_object) # salary_level must be acquired on person - person.reindexObject(); get_transaction().commit(); self.tic() + person.reindexObject(); transaction.commit(); self.tic() self.failUnless(person in salary_level_object.getSalaryLevelRelatedValueList()) @@ -601,7 +601,7 @@ class TestERP5Base(ERP5TypeTestCase): self.assertEquals(person.getCareerSkillTitle(), skill_title_list[0]) self.assertEquals(person.getCareerSkillValue(), skill_object_list[0]) # skill must be acquired on person - person.reindexObject(); get_transaction().commit(); self.tic() + person.reindexObject(); transaction.commit(); self.tic() for skill_object in skill_object_list: self.failUnless(person in skill_object.getSkillRelatedValueList()) self.assertEquals(person.getSkillValue(), skill_object_list[0]) diff --git a/product/ERP5/tests/testERP5Budget.py b/product/ERP5/tests/testERP5Budget.py index 372d1d23b4..c1a74529f8 100644 --- a/product/ERP5/tests/testERP5Budget.py +++ b/product/ERP5/tests/testERP5Budget.py @@ -27,6 +27,7 @@ import unittest +import transaction from zLOG import LOG from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -146,7 +147,7 @@ class TestBudget(ERP5TypeTestCase): self.getAccountingModule().manage_addLocalRoles('maurice', ('Assignor','Assignee','Manager','Owner',)) # flush activities - get_transaction().commit() + transaction.commit() self.tic() # When using light install, only base categories are created if len(self.portal_categories.region.contentValues()) == 0 : @@ -310,7 +311,7 @@ class TestBudget(ERP5TypeTestCase): stop_date='2005/05/01 18:06:26.388 GMT-4') # flush activities - get_transaction().commit() + transaction.commit() self.tic() def getAccountModule(self): diff --git a/product/ERP5/tests/testERP5Category.py b/product/ERP5/tests/testERP5Category.py index 51bd27978f..85049d8117 100644 --- a/product/ERP5/tests/testERP5Category.py +++ b/product/ERP5/tests/testERP5Category.py @@ -27,6 +27,7 @@ ############################################################################## import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.Base import _aq_reset from AccessControl.SecurityManagement import newSecurityManager @@ -139,7 +140,7 @@ class TestERP5Category(ERP5TypeTestCase): predicate.setCriterion('quantity', identity=None, min=None, max=None) self.predicate = predicate - get_transaction().commit() # If we don't commit, then we can't rename + transaction.commit() # If we don't commit, then we can't rename self.tic() def beforeTearDown(self): @@ -168,7 +169,7 @@ class TestERP5Category(ERP5TypeTestCase): def commitAndTic(self): """Just to save one line. """ - get_transaction().commit() + transaction.commit() self.tic() def test_01_RenameCategory(self, quiet=quiet, run=run_all_test): @@ -340,7 +341,7 @@ class TestERP5Category(ERP5TypeTestCase): self.assertEquals([], ctool.getAcquiredCategoryList(doc)) # XXX this test's beforeTearDown commits transaction - get_transaction().abort() + transaction.abort() def test_suite(): diff --git a/product/ERP5/tests/testERP5Core.py b/product/ERP5/tests/testERP5Core.py index 112ec9c116..5d9e4f6183 100644 --- a/product/ERP5/tests/testERP5Core.py +++ b/product/ERP5/tests/testERP5Core.py @@ -30,6 +30,7 @@ import unittest import md5 +import transaction from AccessControl.SecurityManagement import newSecurityManager from Testing import ZopeTestCase from Products.PageTemplates.GlobalTranslationService import \ @@ -67,11 +68,11 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): self.auth = '%s:%s' % (self.manager_username, self.manager_password) def beforeTearDown(self): - get_transaction().abort() + transaction.abort() if 'test_folder' in self.portal.objectIds(): self.portal.manage_delObjects(['test_folder']) self.portal.portal_selections.setSelectionFor('test_selection', None) - get_transaction().commit() + transaction.commit() self.tic() def test_01_ERP5Site_createModule(self, quiet=quiet, run=run_all_test): @@ -284,12 +285,12 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): # Login as the above user newSecurityManager(None, user) self.auth = '%s:%s' % (login_name, password) - get_transaction().commit() + transaction.commit() # Create preference portal.portal_preferences.newContent('Preference', title='My Test Preference') - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual( @@ -306,14 +307,14 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): uid_list = [document_1.getUid(), document_2.getUid()] self.portal.portal_selections.setSelectionParamsFor( 'test_selection', dict(uids=uid_list)) - get_transaction().commit() + transaction.commit() self.tic() md5_string = md5.new(str(sorted([str(x) for x in uid_list]))).hexdigest() redirect = module.Folder_delete(selection_name='test_selection', uids=uid_list, md5_object_uid_list=md5_string) self.assert_('Deleted.' in redirect, redirect) - get_transaction().commit(1) + transaction.commit(1) self.assertEquals(len(module.objectValues()), 0) def test_Folder_delete_related_object(self): @@ -328,7 +329,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): uid_list = [document_1.getUid(), document_2.getUid()] self.portal.portal_selections.setSelectionParamsFor( 'test_selection', dict(uids=uid_list)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals([document_1], self.portal.portal_categories.getRelatedValueList(document_2)) @@ -337,7 +338,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): uids=uid_list, md5_object_uid_list=md5_string) self.assert_('Sorry, 1 item is in use.' in redirect, redirect) - get_transaction().commit(1) + transaction.commit(1) self.assertEquals(len(module.objectValues()), 2) @@ -354,7 +355,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): uid_list = [document_2.getUid(), ] self.portal.portal_selections.setSelectionParamsFor( 'test_selection', dict(uids=uid_list)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals([document_1], self.portal.portal_categories.getRelatedValueList(document_2)) @@ -366,7 +367,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): uids=uid_list, md5_object_uid_list=md5_string) self.assert_('Sorry, 1 item is in use.' in redirect, redirect) - get_transaction().commit(1) + transaction.commit(1) self.assertEquals(len(module.objectValues()), 2) diff --git a/product/ERP5/tests/testERP5CurrencyExchangeLine.py b/product/ERP5/tests/testERP5CurrencyExchangeLine.py index 0c24553acf..46f915c3a1 100644 --- a/product/ERP5/tests/testERP5CurrencyExchangeLine.py +++ b/product/ERP5/tests/testERP5CurrencyExchangeLine.py @@ -27,6 +27,7 @@ ############################################################################## import unittest import os +import transaction from DateTime import DateTime from zLOG import LOG from Products.CMFCore.utils import _checkPermission @@ -61,7 +62,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): """ username = 'username' def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary currency_list = ('euro', 'yen', 'usd') module = self.portal.currency_module @@ -73,7 +74,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): currency.manage_delObjects([x.getId() for x in currency.objectValues( portal_type='Currency Exchange Line')]) - get_transaction().commit() + transaction.commit() self.tic() def login(self,name=username, quiet=0, run=run_all_test): @@ -141,7 +142,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction self.organisation1.edit( price_currency=new_currency.getRelativeUrl()) @@ -198,7 +199,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction self.organisation1.edit( price_currency=new_currency.getRelativeUrl()) @@ -268,7 +269,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction self.organisation1.edit( price_currency=new_currency.getRelativeUrl()) @@ -322,7 +323,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction self.organisation1.edit( price_currency=new_currency.getRelativeUrl()) @@ -365,7 +366,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction self.organisation1.edit( price_currency=new_currency.getRelativeUrl()) @@ -435,7 +436,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction self.organisation1.edit( price_currency=new_currency.getRelativeUrl()) @@ -491,7 +492,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): new_currency.setReference('XOF') new_currency.setTitle('Francs CFA') new_currency.setBaseUnitQuantity(1.00) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction self.organisation1.edit( price_currency=new_currency.getRelativeUrl()) diff --git a/product/ERP5/tests/testERP5Web.py b/product/ERP5/tests/testERP5Web.py index fb62423891..1c3579ac84 100644 --- a/product/ERP5/tests/testERP5Web.py +++ b/product/ERP5/tests/testERP5Web.py @@ -33,6 +33,7 @@ import re import unittest import random +import transaction from AccessControl import Unauthorized from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import getSecurityManager @@ -80,11 +81,10 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): def clearModule(self, module): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): -# get_transaction().abort() self.clearModule(self.portal.web_site_module) self.clearModule(self.portal.web_page_module) self.clearModule(self.portal.person_module) @@ -107,7 +107,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): website = self.getPortal().web_site_module.newContent(portal_type = 'Web Site', id = self.website_id, **kw) - get_transaction().commit() + transaction.commit() self.tic() return website @@ -128,7 +128,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): max='', min='') - get_transaction().commit() + transaction.commit() self.tic() return websection @@ -156,7 +156,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): language=language, **kw) webpage.publish() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(language, webpage.getLanguage()) self.assertEquals(reference, webpage.getReference()) @@ -224,7 +224,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): website = portal.web_site_module[self.website_id] website.WebSite_createWebSiteAccount('WebSite_viewRegistrationDialog') - get_transaction().commit() + transaction.commit() self.tic() # find person object by reference @@ -341,12 +341,12 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): reference='NXD-DDP', publication_section_list=publication_section_category_id_list[:1]) websection.setAggregateValue(web_page_en) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(None, websection.getDefaultDocumentValue()) # publish it web_page_en.publish() - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(web_page_en, websection.getDefaultDocumentValue()) # and make sure that the base meta tag which is generated @@ -384,12 +384,12 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): reference='NXD-DDP-Site', publication_section_list=publication_section_category_id_list[:1]) website.setAggregateValue(web_page_en) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(None, website.getDefaultDocumentValue()) # publish it web_page_en.publish() - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(web_page_en, website.getDefaultDocumentValue()) # and make sure that the base meta tag which is generated @@ -463,11 +463,11 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): publication_section_list=publication_section_category_id_list[:1]) web_page.edit(**property_dict[key]) - get_transaction().commit() + transaction.commit() self.tic() web_page_list.append(web_page) - get_transaction().commit() + transaction.commit() self.tic() # in draft state no documents should belong to this Web Section self.assertEqual(0, len(websection.getDocumentValueList())) @@ -475,7 +475,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): # when published all web pages should belong to it for web_page in web_page_list: web_page.publish() - get_transaction().commit() + transaction.commit() self.tic() # Test for limit parameter @@ -638,7 +638,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): publication_section.newContent(portal_type='Category', id='my_test_category', title='Test') - get_transaction().commit() + transaction.commit() self.tic() website = self.setupWebSite() @@ -658,7 +658,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): # We need a default document. websection.setAggregateValue(web_page_list[0]) - get_transaction().commit() + transaction.commit() self.tic() # Obtain documens in various ways. @@ -694,7 +694,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): # First, make sure that we use the default skin selection. portal.changeSkin(ps.getDefaultSkin()) - get_transaction().commit() + transaction.commit() self.tic() # Make some skin stuff. @@ -720,7 +720,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): 'WebSite_test_13_WebSiteSkinSelection', '', 'return "bar"') - get_transaction().commit() + transaction.commit() self.tic() path = website.absolute_url_path() + '/WebSite_test_13_WebSiteSkinSelection' @@ -732,7 +732,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): # With the test skin. website.setSkinSelectionName('Test ERP5 Web') - get_transaction().commit() + transaction.commit() self.tic() request['PARENTS'] = [self.app] @@ -778,7 +778,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): # Commit transaction def _commit(): portal.portal_caches.clearAllCache() - get_transaction().commit() + transaction.commit() self.tic() # By default, as now Web Section is visible, nothing should be returned @@ -844,12 +844,12 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): self.createUser('admin', ['Manager']) self.createUser('erp5user', ['Auditor', 'Author']) self.createUser('webmaster', ['Assignor']) - get_transaction().commit() + transaction.commit() self.tic() def clearModule(self, module): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): @@ -867,13 +867,13 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): id='site') section = site.newContent(portal_type='Web Section', id='section') - get_transaction().commit() + transaction.commit() self.tic() section.setCriterionProperty('portal_type') section.setCriterion('portal_type', max='', identity=['Web Page'], min='') - get_transaction().commit() + transaction.commit() self.tic() self.changeUser('erp5user') @@ -884,12 +884,12 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): text_format='text/plain', text_content='Hello, World!') - get_transaction().commit() + transaction.commit() self.tic() page_en.publish() - get_transaction().commit() + transaction.commit() self.tic() page_ja = self.portal.web_page_module.newContent(portal_type='Web Page') @@ -899,12 +899,12 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): text_format='text/plain', text_content='ã“ã‚“ã«ã¡ã¯ã€ä¸–ç•Œï¼') - get_transaction().commit() + transaction.commit() self.tic() page_ja.publish() - get_transaction().commit() + transaction.commit() self.tic() # By Anonymous @@ -940,7 +940,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): section_role_definition = section.newContent(portal_type = 'Role Definition', role_name = 'Associate', agent = person.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() # check if Role Definition have create local roles self.assertSameSet(('Assignee',), @@ -951,7 +951,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): # delete Role Definition and check again (local roles must be gone too) site.manage_delObjects(site_role_definition.getId()) section.manage_delObjects(section_role_definition.getId()) - get_transaction().commit() + transaction.commit() self.tic() self.assertSameSet((), site.get_local_roles_for_userid(person_reference)) @@ -973,14 +973,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): section = site.newContent(portal_type='Web Section', id='section') - get_transaction().commit() + transaction.commit() self.tic() section.setCriterionProperty('portal_type') section.setCriterion('portal_type', max='', identity=['Web Page'], min='') - get_transaction().commit() + transaction.commit() self.tic() self.changeUser('erp5user') @@ -1014,7 +1014,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): - get_transaction().commit() + transaction.commit() self.changeUser('erp5user') self.tic() self.portal.Localizer.changeLanguage('en') @@ -1023,7 +1023,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): self.changeUser('erp5user') page_en_0.publish() - get_transaction().commit() + transaction.commit() self.tic() self.portal.Localizer.changeLanguage('en') @@ -1046,7 +1046,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): # Second Object self.changeUser('erp5user') page_en_1.publish() - get_transaction().commit() + transaction.commit() self.tic() self.portal.Localizer.changeLanguage('en') @@ -1066,7 +1066,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): # Trird Object self.changeUser('erp5user') page_en_2.publish() - get_transaction().commit() + transaction.commit() self.tic() self.portal.Localizer.changeLanguage('en') @@ -1084,7 +1084,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): # First Japanese Object self.changeUser('erp5user') page_jp_0.publish() - get_transaction().commit() + transaction.commit() self.tic() self.portal.Localizer.changeLanguage('en') @@ -1120,7 +1120,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): section_4 = site.newContent(portal_type='Web Section', id='section_4') section_5 = section_3.newContent(portal_type='Web Section', id='section_5') section_6 = section_4.newContent(portal_type='Web Section', id='section_6') - get_transaction().commit() + transaction.commit() self.tic() # test if a manager can expire them @@ -1282,7 +1282,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): id='new_category_2') except Unauthorized: self.fail("Admin should be able to create a Category.") - get_transaction().commit() + transaction.commit() self.tic() try: new_cat_1_renamed = new_category_1.edit(id='new_cat_1_renamed') @@ -1303,7 +1303,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): id='new_category_4') except Unauthorized: self.fail("A webmaster should be able to create a Category.") - get_transaction().commit() + transaction.commit() self.tic() try: new_cat_3_renamed = new_category_3.edit(id='new_cat_3_renamed') diff --git a/product/ERP5/tests/testERP5WebWithDms.py b/product/ERP5/tests/testERP5WebWithDms.py index 2807ea4f96..0882fe04ca 100644 --- a/product/ERP5/tests/testERP5WebWithDms.py +++ b/product/ERP5/tests/testERP5WebWithDms.py @@ -31,6 +31,7 @@ import re import unittest import random +import transaction from AccessControl import Unauthorized from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import getSecurityManager @@ -78,7 +79,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): def clearModule(self, module): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): @@ -103,7 +104,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): website = self.getPortal().web_site_module.newContent(portal_type = 'Web Site', id = self.website_id, **kw) - get_transaction().commit() + transaction.commit() self.tic() return website @@ -124,7 +125,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): max='', min='') - get_transaction().commit() + transaction.commit() self.tic() return websection @@ -152,7 +153,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): language=language, **kw) webpage.publish() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(language, webpage.getLanguage()) self.assertEquals(reference, webpage.getReference()) @@ -196,7 +197,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): language = 'en') en_02.publish() en_02.reindexObject() - get_transaction().commit() + transaction.commit() self.tic() # is old archived? @@ -231,7 +232,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): document.release() website.setAuthorizationForced(0) websection.setAuthorizationForced(0) - get_transaction().commit() + transaction.commit() self.tic() # make sure that _getExtensibleContent will return the same document @@ -273,7 +274,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): websection.edit(membership_criterion_base_category = ['publication_section'], membership_criterion_category=['publication_section/%s' %publication_section_category_id_list[0]]) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(0, len(websection.getDocumentValueList())) @@ -282,7 +283,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): language = 'en', publication_section_list=publication_section_category_id_list[:1]) web_page_en.publish() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(1, len(websection.getDocumentValueList(language='en'))) self.assertEquals(web_page_en, websection.getDocumentValueList(language='en')[0].getObject()) @@ -292,20 +293,20 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): language = 'bg', publication_section_list=publication_section_category_id_list[:1]) web_page_bg.publish() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(1, len(websection.getDocumentValueList(language='bg'))) self.assertEquals(web_page_bg, websection.getDocumentValueList(language='bg')[0].getObject()) # reject page web_page_bg.reject() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(0, len(websection.getDocumentValueList(language='bg'))) # publish page and search without a language (by default system should return 'en' docs only) web_page_bg.publish() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(1, len(websection.getDocumentValueList())) self.assertEquals(web_page_en, websection.getDocumentValueList()[0].getObject()) @@ -331,7 +332,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): web_page_en.releaseAlive() websection.setAggregateValue(web_page_en) websection.setAuthorizationForced(1) - get_transaction().commit() + transaction.commit() self.tic() # make sure that getDefaultDocumentValue() will return the same document for logged in user @@ -347,7 +348,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): # Anonymous User should not get Unauthorized when authorization_forced is not set self.login() websection.setAuthorizationForced(0) - get_transaction().commit() + transaction.commit() self.tic() self.logout() @@ -365,11 +366,11 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): language = 'en',) web_page.publish() self.tic() - get_transaction().commit() + transaction.commit() web_page_list.append(web_page) websection.setAggregateValueList(web_page_list) self.tic() - get_transaction().commit() + transaction.commit() self.assertEqual(5, len(websection.getDocumentValueList(limit=5))) def test_05_deadProxyFields(self, quiet=quiet, run=run_all_test): diff --git a/product/ERP5/tests/testICal.py b/product/ERP5/tests/testICal.py index 073e2c6552..5d8eec6ed6 100644 --- a/product/ERP5/tests/testICal.py +++ b/product/ERP5/tests/testICal.py @@ -41,15 +41,12 @@ import unittest +import transaction + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager from Products.ERP5Form.Form import ERP5Form -try: - from transaction import get as get_transaction -except ImportError: - pass - class TestICal(ERP5TypeTestCase): @@ -83,7 +80,7 @@ class TestICal(ERP5TypeTestCase): if hasattr(self.portal.person_module, 'one'): self.portal.person_module.manage_delObjects(['one']) one = self.portal.person_module.newContent(id="one", title="One", description="Person One") - get_transaction().commit() + transaction.commit() self.tic() def parseICalFeed(self, feed_string): @@ -121,7 +118,7 @@ class TestICal(ERP5TypeTestCase): if not run: return module = self.portal.event_module event = module.newContent(id='one', title='Event One', portal_type='Phone Call') - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -147,7 +144,7 @@ class TestICal(ERP5TypeTestCase): event.receive() event.setStartDate('2007/08/15 10:30') event.setDescription('Event One description') - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -161,7 +158,7 @@ class TestICal(ERP5TypeTestCase): # check categorization sale_op = self.portal.sale_opportunity_module.newContent(portal_type='Sale Opportunity', title='New Opportunity', reference='NEWSALEOP') event.setFollowUp(sale_op.getRelativeUrl()) - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -170,7 +167,7 @@ class TestICal(ERP5TypeTestCase): # set stop date and change workflow state - assigned event.assign() event.setStopDate('2007/08/15 15:30') - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -179,7 +176,7 @@ class TestICal(ERP5TypeTestCase): # cancel event event.cancel() - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -195,7 +192,7 @@ class TestICal(ERP5TypeTestCase): if not run: return module = self.portal.task_module task = module.newContent(id='one', title='Task One', start_date='2007/08/15') - get_transaction().commit() + transaction.commit() self.tic() # current workflow state - draft @@ -212,7 +209,7 @@ class TestICal(ERP5TypeTestCase): title='New Project', reference='NEWPROJ') task.setSourceProjectValue(project) - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -220,7 +217,7 @@ class TestICal(ERP5TypeTestCase): # change workflow state - planned task.plan() - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -229,7 +226,7 @@ class TestICal(ERP5TypeTestCase): # change workflow state - ordered task.order() - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) @@ -238,7 +235,7 @@ class TestICal(ERP5TypeTestCase): # change workflow state - confirmed task.confirm() - get_transaction().commit() + transaction.commit() self.tic() feed_dict = self.getICalFeed(module) diff --git a/product/ERP5/tests/testIdTool.py b/product/ERP5/tests/testIdTool.py index e26f163369..7f8f609df5 100644 --- a/product/ERP5/tests/testIdTool.py +++ b/product/ERP5/tests/testIdTool.py @@ -27,6 +27,7 @@ ############################################################################## import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from DateTime import DateTime @@ -61,19 +62,19 @@ class TestIdTool(ERP5TypeTestCase): idtool = self.portal.portal_ids # test with value stored into zodb new_id = idtool.generateNewLengthId(id_group=4, store=1) - get_transaction().commit() + transaction.commit() self.tic() last_id = idtool.getLastLengthGeneratedId(id_group=4) self.assertEqual(new_id, last_id) # same test without storing value into zodb new_id = idtool.generateNewLengthId(id_group=5, store=0) - get_transaction().commit() + transaction.commit() self.tic() last_id = idtool.getLastLengthGeneratedId(id_group=5) self.assertEqual(new_id, last_id) # test with id_group as tuple new_id = idtool.generateNewLengthId(id_group=(6,), store=0) - get_transaction().commit() + transaction.commit() self.tic() last_id = idtool.getLastLengthGeneratedId(id_group=(6,),) self.assertEqual(new_id, last_id) diff --git a/product/ERP5/tests/testImmobilisation.py b/product/ERP5/tests/testImmobilisation.py index d3ececf16e..2893206e87 100644 --- a/product/ERP5/tests/testImmobilisation.py +++ b/product/ERP5/tests/testImmobilisation.py @@ -28,6 +28,7 @@ import unittest +import transaction from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.Sequence import SequenceList @@ -35,10 +36,6 @@ from DateTime import DateTime from zLOG import LOG from Products.ERP5.Document.ImmobilisationMovement import UNIMMOBILISING_METHOD, NO_CHANGE_METHOD -try: - from transaction import get as get_transaction -except ImportError: - pass class TestImmobilisationMixin(ERP5TypeTestCase): run_all_test = 1 @@ -73,7 +70,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): """ For debugging """ - get_transaction().commit() + transaction.commit() def getBusinessTemplateList(self): """ @@ -231,7 +228,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): self.createAccountList() self.createItemList() self.validateRules() - get_transaction().commit() + transaction.commit() self.tic() self.workflow_tool = self.getWorkflowTool() @@ -244,7 +241,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): self.logout() self.login('manager') - get_transaction().commit() + transaction.commit() self.tic() simulation_id_list = [r for r in self.getPortal().portal_simulation.objectIds()] @@ -261,7 +258,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): id_list = [r for r in self.getAccountingModule().objectIds()] self.getAccountingModule().manage_delObjects(id_list) - get_transaction().commit() + transaction.commit() self.tic() def createCategories(self): @@ -352,7 +349,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): mapping = mapping, ) ##We need to commit here because edit organisation doesn't apply - #get_transaction().commit() + #transaction.commit() #self.tic() for organisation_id in ['A','Aa','Ab','B','Ba','Bb','standalone']: organisation = organisation_module[organisation_id] @@ -459,14 +456,14 @@ class TestImmobilisationMixin(ERP5TypeTestCase): pl = sequence.get('packing_list') if pl is None: pl = sequence.get('packing_list_list', [])[-1] self.workflow_tool.doActionFor(pl, 'confirm_action', wf_id='packing_list_workflow') - get_transaction().commit() + transaction.commit() self.tic() self.workflow_tool.doActionFor(pl, 'set_ready_action', wf_id='packing_list_workflow') self.workflow_tool.doActionFor(pl, 'start_action', wf_id='packing_list_workflow') - get_transaction().commit() + transaction.commit() self.tic() self.workflow_tool.doActionFor(pl, 'stop_action', wf_id='packing_list_workflow') - get_transaction().commit() + transaction.commit() self.tic() #self.workflow_tool.doActionFor(pl, 'deliver_action', wf_id='packing_list_workflow') @@ -495,7 +492,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): pl_line = pl.newContent(portal_type = self.packing_list_line_portal_type) pl_line.edit(aggregate_value_list = item_list, resource_value=resource_value, **parameter_dict) - get_transaction().commit() + transaction.commit() self.tic() #pl.calculateImmobilisationValidity() @@ -576,10 +573,10 @@ class TestImmobilisationMixin(ERP5TypeTestCase): def stepValidateAccounting(self, sequence=None, sequence_list=None, **kw): for transaction in self.getAccountingModule().contentValues(): transaction.stop() - get_transaction().commit() + transaction.commit() self.tic() transaction.deliver() - get_transaction().commit() + transaction.commit() self.tic() def stepTestPackingListInvalidImmobilisationState(self, sequence=None, sequence_list=None, **kw): @@ -935,7 +932,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): self.stepCreatePackingList(sequence=sequence) self.stepAggregateItems(sequence=sequence) self.stepDeliverPackingList(sequence=sequence) - get_transaction().commit() + transaction.commit() self.tic() for property in ('amortisation_start_price','amortisation_duration','immobilisation_vat', 'extra_cost_price','disposal_price'): @@ -949,7 +946,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): self.stepCreatePackingList(sequence=sequence) self.stepAggregateItems(sequence=sequence) self.stepDeliverPackingList(sequence=sequence) - get_transaction().commit() + transaction.commit() self.tic() parameter_dict.update(self.monthly_dict) sequence.edit(datetime = DateTime('2002/04/16'), @@ -957,7 +954,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): self.stepCreatePackingList(sequence=sequence) self.stepAggregateItems(sequence=sequence) self.stepDeliverPackingList(sequence=sequence) - get_transaction().commit() + transaction.commit() self.tic() sequence.edit(datetime = DateTime('2002/05/16'), parameter_dict = parameter_dict, @@ -965,7 +962,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): self.stepCreatePackingList(sequence=sequence) self.stepAggregateItems(sequence=sequence) self.stepDeliverPackingList(sequence=sequence) - get_transaction().commit() + transaction.commit() self.tic() sequence.edit(datetime = DateTime('2002/06/16'), parameter_dict = parameter_dict, @@ -973,7 +970,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): self.stepCreatePackingList(sequence=sequence) self.stepAggregateItems(sequence=sequence) self.stepDeliverPackingList(sequence=sequence) - get_transaction().commit() + transaction.commit() self.tic() def stepBuildAccounting(self, sequence=None, sequence_list=None, **kw): @@ -3646,7 +3643,7 @@ class TestImmobilisation(TestImmobilisationMixin): 'currency_module/EUR') wf_tool = self.getWorkflowTool() wf_tool.doActionFor(preference,'enable_action',wf_id='preference_workflow') - get_transaction().commit() + transaction.commit() self.tic() # Now we can check several Accounting methods account = self.getPortal().account_module.account3 @@ -3654,7 +3651,7 @@ class TestImmobilisation(TestImmobilisationMixin): self.assertEquals(10000.0,account.AccountModule_getTotalSourceCredit(brain=account)) preference.edit(preferred_accounting_transaction_section_category=\ 'group/group B') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('group/group B', preference_tool.getPreferredAccountingTransactionSectionCategory()) diff --git a/product/ERP5/tests/testInteractionWorkflow.py b/product/ERP5/tests/testInteractionWorkflow.py index 367b272951..00ac423af1 100644 --- a/product/ERP5/tests/testInteractionWorkflow.py +++ b/product/ERP5/tests/testInteractionWorkflow.py @@ -28,6 +28,7 @@ import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.Base import _aq_reset from AccessControl.SecurityManagement import newSecurityManager @@ -524,7 +525,7 @@ context.setDescription('%s,%s,%s' % (d, args, result)) self.assertEquals(organisation.getDescription(), 'bad') organisation.getProperty('description', d='toto') self.assertEquals(organisation.getDescription(), 'bad') - get_transaction().commit() + transaction.commit() self.assertEquals(organisation.getDescription(), "toto,('description',),bad") def test_17_activity_interaction(self, quiet=0, run=run_all_test): @@ -548,7 +549,7 @@ context.setTitle('Bar') organisation.setTitle('Foo') organisation.setGroupValue(organisation) self.assertEquals(organisation.getTitle(), 'Foo') - get_transaction().commit() + transaction.commit() self.assertEquals(organisation.getTitle(), 'Foo') self.tic() self.assertEquals(organisation.getTitle(), 'Bar') diff --git a/product/ERP5/tests/testInventory.py b/product/ERP5/tests/testInventory.py index ecc51adb08..96f2040db8 100644 --- a/product/ERP5/tests/testInventory.py +++ b/product/ERP5/tests/testInventory.py @@ -40,6 +40,8 @@ import unittest +import transaction + from Products.ERP5Type.Utils import cartesianProduct from copy import copy @@ -307,14 +309,14 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): workflow_tool = self.getPortal().portal_workflow workflow_tool.doActionFor(packing_list, "confirm_action", "packing_list_workflow") - get_transaction().commit() + transaction.commit() # Apply tic so that the packing list is not in building state self.tic() # acceptable here because this is not the job # of the test to check if can do all transition # without processing messages workflow_tool.doActionFor(packing_list, "set_ready_action", "packing_list_workflow") - get_transaction().commit() + transaction.commit() self.tic() workflow_tool.doActionFor(packing_list, "start_action", "packing_list_workflow") @@ -1194,7 +1196,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): LOG("Transiting '%s' on packing list %s" % (action, transition_step['id']), 0, '') workflow_tool.doActionFor(transited_pl, action, packing_list_workflow) transited_pl.recursiveImmediateReindexObject() # XXX - get_transaction().commit() + transaction.commit() self.stepTic() for omit_transit in (0,1): @@ -1685,9 +1687,9 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ) sequence.edit(packing_list_list = packing_list_list) - get_transaction().commit() + transaction.commit() self.stepTic() - get_transaction().commit() + transaction.commit() # Then test the next negative date next_date = simulation.getNextNegativeInventoryDate( diff --git a/product/ERP5/tests/testInventoryAPI.py b/product/ERP5/tests/testInventoryAPI.py index 0623c67541..1503a21f4b 100644 --- a/product/ERP5/tests/testInventoryAPI.py +++ b/product/ERP5/tests/testInventoryAPI.py @@ -36,6 +36,7 @@ import os import random import unittest +import transaction from AccessControl.SecurityManagement import newSecurityManager from DateTime import DateTime from Testing import ZopeTestCase @@ -127,7 +128,7 @@ class InventoryAPITestCase(ERP5TypeTestCase): def _safeTic(self): """Like tic, but swallowing errors, usefull for teardown""" try: - get_transaction().commit() + transaction.commit() self.tic() except RuntimeError: pass @@ -153,7 +154,7 @@ class InventoryAPITestCase(ERP5TypeTestCase): activity_tool.manageCancel(message.object_path, message.method_id) ZopeTestCase._print('\nCancelling active message %s.%s()\n' % (message.object_path, message.method_id) ) - get_transaction().commit() + transaction.commit() def login(self, quiet=0, run=1): uf = self.getPortal().acl_users @@ -228,7 +229,7 @@ class InventoryAPITestCase(ERP5TypeTestCase): """Creates a product.""" product = self.getProductModule().newContent( portal_type = 'Product', **kw) - get_transaction().commit() + transaction.commit() self.tic() return product _makeResource = _makeProduct @@ -297,7 +298,7 @@ class TestInventory(InventoryAPITestCase): sim_mvt.setDeliveryValue(mvt) self.failIf(sim_mvt.isAccountable()) # not accountable movement are not counted by getInventory - get_transaction().commit(); self.tic() # (after reindexing of course) + transaction.commit(); self.tic() # (after reindexing of course) self.assertEquals(100, getInventory(section_uid=self.section.getUid())) def test_OmitSimulation(self): @@ -330,7 +331,7 @@ class TestInventory(InventoryAPITestCase): self.assertEquals(getInventory( section_category_strict_membership=['group/level1']), 0) self.section.setGroup('level1') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(getInventory( section_category_strict_membership=['group/level1']), 100) @@ -363,7 +364,7 @@ class TestInventory(InventoryAPITestCase): self.assertEquals(getInventory( mirror_section_category_strict_membership=['group/level1']), 0) self.mirror_section.setGroup('level1') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(getInventory( mirror_section_category_strict_membership=['group/level1']), 100) @@ -387,7 +388,7 @@ class TestInventory(InventoryAPITestCase): self.assertEquals(getInventory( node_category_strict_membership=['group/level1']), 0) self.node.setGroup('level1') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(getInventory( node_category_strict_membership=['group/level1']), 100) @@ -405,7 +406,7 @@ class TestInventory(InventoryAPITestCase): self.assertEquals(getInventory( resource_category_strict_membership=['product_line/level1']), 0) self.resource.setProductLine('level1') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(getInventory( resource_category_strict_membership=['product_line/level1']), 100) @@ -426,7 +427,7 @@ class TestInventory(InventoryAPITestCase): self.assertEquals(getInventory( payment_category_strict_membership=['product_line/level1']), 0) self.payment_node.setProductLine('level1') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(getInventory( payment_category_strict_membership=['product_line/level1']), 100) @@ -2003,7 +2004,7 @@ class TestInventoryDocument(InventoryAPITestCase): # everything must be consistent after reindexation inventory_module = self.getPortal().getDefaultModule(portal_type='Inventory') inventory_module.recursiveReindexObject() - get_transaction().commit() + transaction.commit() self.tic() inventory_kw={'node_uid': self.node_uid, 'at_date': self.INVENTORY_DATE_3} @@ -2050,7 +2051,7 @@ class TestInventoryDocument(InventoryAPITestCase): self.workflow_tool.doActionFor(inventory, transition_id, wf_id=workflow_id) self.assertEquals('delivered', inventory.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() # We should detect the previous inventory and fails @@ -2069,7 +2070,7 @@ class TestInventoryDocument(InventoryAPITestCase): self.workflow_tool.doActionFor(new_inventory, transition_id, wf_id=workflow_id) self.assertEquals('delivered', new_inventory.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() new_inventory = new_inventory.Base_createCloneDocument(batch_mode=1) @@ -2089,7 +2090,7 @@ class TestInventoryDocument(InventoryAPITestCase): if psheet in ps_list: ps_list.remove(psheet) ti.property_sheet_list = ps_list - get_transaction().commit() + transaction.commit() _aq_reset() diff --git a/product/ERP5/tests/testInvoice.py b/product/ERP5/tests/testInvoice.py index ca342773fd..2fab90cd30 100644 --- a/product/ERP5/tests/testInvoice.py +++ b/product/ERP5/tests/testInvoice.py @@ -31,6 +31,7 @@ """ +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod @@ -43,11 +44,6 @@ from Products.ERP5Type.tests.Sequence import SequenceList from testPackingList import TestPackingListMixin from testAccountingRules import TestAccountingRulesMixin -try: - from transaction import get as get_transaction -except ImportError: - pass - class TestInvoiceMixin(TestPackingListMixin, TestAccountingRulesMixin,): """Test methods for invoices @@ -130,7 +126,7 @@ class TestInvoiceMixin(TestPackingListMixin, self.login() def beforeTearDown(self): - get_transaction().abort() + transaction.abort() self.tic() for folder in (self.portal.accounting_module, self.portal.organisation_module, @@ -140,7 +136,7 @@ class TestInvoiceMixin(TestPackingListMixin, self.portal.purchase_packing_list_module, self.portal.portal_simulation,): folder.manage_delObjects(list(folder.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def login(self): @@ -178,7 +174,7 @@ class TestInvoiceMixin(TestPackingListMixin, invoice_rule = portal.portal_rules.default_invoice_transaction_rule invoice_rule.deleteContent([x.getId() for x in invoice_rule.objectValues()]) - get_transaction().commit() + transaction.commit() self.tic() region_predicate = invoice_rule.newContent(portal_type = 'Predicate') product_line_predicate = invoice_rule.newContent(portal_type = 'Predicate') @@ -213,7 +209,7 @@ class TestInvoiceMixin(TestPackingListMixin, destination_value=account_module[line_destination_id]) invoice_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() def stepCreateEntities(self, sequence, **kw) : @@ -366,7 +362,7 @@ class TestInvoice(TestInvoiceMixin): price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule = order.getCausalityRelatedValue( @@ -425,7 +421,7 @@ class TestInvoice(TestInvoiceMixin): title='Other Entity', price_currency=currency.getRelativeUrl()) order.plan() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('planned', order.getSimulationState()) @@ -436,21 +432,21 @@ class TestInvoice(TestInvoiceMixin): invoice_movement = invoice_applied_rule.contentValues()[0] order_line.setSourceValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getSourceValue()) order_line.setDestinationValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getDestinationValue()) order_line.setSourceSectionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, @@ -461,77 +457,77 @@ class TestInvoice(TestInvoiceMixin): order_line.setSourceSectionValue(order_line.getDestinationSectionValue()) order_line.setDestinationSectionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getDestinationSectionValue()) order_line.setSourceAdministrationValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getSourceAdministrationValue()) order_line.setDestinationAdministrationValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getDestinationAdministrationValue()) order_line.setSourceDecisionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getSourceDecisionValue()) order_line.setDestinationDecisionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getDestinationDecisionValue()) order_line.setSourceProjectValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getSourceProjectValue()) order_line.setDestinationProjectValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getDestinationProjectValue()) order_line.setSourcePaymentValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getSourcePaymentValue()) order_line.setDestinationPaymentValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getDestinationPaymentValue()) order_line.setSourceFunctionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, invoice_movement.getSourceFunctionValue()) order_line.setDestinationFunctionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_entity, @@ -539,7 +535,7 @@ class TestInvoice(TestInvoiceMixin): self.assertNotEquals(123, order_line.getPrice()) order_line.setPrice(123) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(123, @@ -547,7 +543,7 @@ class TestInvoice(TestInvoiceMixin): self.assertNotEquals(456, order_line.getQuantity()) order_line.setQuantity(456) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(456, @@ -557,21 +553,21 @@ class TestInvoice(TestInvoiceMixin): portal_type='Product', title='Other Resource') order_line.setResourceValue(other_resource) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(other_resource, invoice_movement.getResourceValue()) order_line.setStartDate(DateTime(2001, 02, 03)) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(DateTime(2001, 02, 03), invoice_movement.getStartDate()) order_line.setStopDate(DateTime(2002, 03, 04)) - get_transaction().commit() + transaction.commit() self.tic() invoice_movement = invoice_applied_rule.contentValues()[0] self.assertEquals(DateTime(2002, 03, 04), @@ -619,7 +615,7 @@ class TestInvoice(TestInvoiceMixin): title='Other Entity', default_address_region=self.default_region) order.plan() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('planned', order.getSimulationState()) @@ -644,7 +640,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_applied_rule) order_line.setSourceSectionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(other_entity, invoice_transaction_movement.getSourceSectionValue()) @@ -654,7 +650,7 @@ class TestInvoice(TestInvoiceMixin): order_line.setSourceSectionValue(order_line.getDestinationSectionValue()) order_line.setDestinationSectionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -663,7 +659,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getDestinationSectionValue()) order_line.setSourceAdministrationValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -672,7 +668,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getSourceAdministrationValue()) order_line.setDestinationAdministrationValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -681,7 +677,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getDestinationAdministrationValue()) order_line.setSourceDecisionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -690,7 +686,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getSourceDecisionValue()) order_line.setDestinationDecisionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -699,7 +695,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getDestinationDecisionValue()) order_line.setSourceProjectValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -708,7 +704,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getSourceProjectValue()) order_line.setDestinationProjectValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -717,7 +713,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getDestinationProjectValue()) order_line.setSourceFunctionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -726,7 +722,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getSourceFunctionValue()) order_line.setDestinationFunctionValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -735,7 +731,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getDestinationFunctionValue()) order_line.setSourcePaymentValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -744,7 +740,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getSourcePaymentValue()) order_line.setDestinationPaymentValue(other_entity) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -754,7 +750,7 @@ class TestInvoice(TestInvoiceMixin): order_line.setQuantity(1) order_line.setPrice(123) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -764,7 +760,7 @@ class TestInvoice(TestInvoiceMixin): order_line.setQuantity(456) order_line.setPrice(1) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -773,7 +769,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getQuantity()) order_line.setStartDate(DateTime(2001, 02, 03)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -782,7 +778,7 @@ class TestInvoice(TestInvoiceMixin): invoice_transaction_movement.getStartDate()) order_line.setStopDate(DateTime(2002, 03, 04)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(3, len(invoice_transaction_applied_rule)) invoice_transaction_movement = getIncomeSimulationMovement( @@ -813,7 +809,7 @@ class TestInvoice(TestInvoiceMixin): quantity=10, price=3) invoice.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = invoice.Invoice_viewAsODT() @@ -852,7 +848,7 @@ class TestInvoice(TestInvoiceMixin): quantity=10, price=3) invoice.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = invoice.Invoice_viewAsODT() @@ -903,7 +899,7 @@ class TestInvoice(TestInvoiceMixin): quantity=10, price=3) invoice.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = invoice.Invoice_viewAsODT() @@ -961,7 +957,7 @@ class TestInvoice(TestInvoiceMixin): variation_category_list=['size/Child/32'], mapped_value_property_list=['quantity', 'price'],) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( @@ -970,7 +966,7 @@ class TestInvoice(TestInvoiceMixin): related_packing_list.start() related_packing_list.stop() - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_packing_list.getCausalityRelatedValue( @@ -1044,7 +1040,7 @@ class TestInvoice(TestInvoiceMixin): resource_value=resource,) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( @@ -1060,7 +1056,7 @@ class TestInvoice(TestInvoiceMixin): related_packing_list.start() related_packing_list.stop() - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_packing_list.getCausalityRelatedValue( @@ -1110,7 +1106,7 @@ class TestInvoice(TestInvoiceMixin): title='euro') currency.setBaseUnitQuantity(0.01) self.createInvoiceTransactionRule(currency) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -1136,7 +1132,7 @@ class TestInvoice(TestInvoiceMixin): quantity=5, price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type=self.packing_list_portal_type) @@ -1147,7 +1143,7 @@ class TestInvoice(TestInvoiceMixin): order.getIncoterm()) related_packing_list.start() related_packing_list.stop() - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_packing_list.getCausalityRelatedValue( portal_type=self.invoice_portal_type) @@ -1174,7 +1170,7 @@ class TestInvoice(TestInvoiceMixin): portal_type='Currency', title='euro') currency.setBaseUnitQuantity(0.01) - get_transaction().commit() + transaction.commit() self.tic()#execute transaction client = self.portal.organisation_module.newContent( portal_type='Organisation', @@ -1208,7 +1204,7 @@ class TestInvoice(TestInvoiceMixin): quantity=1.5, price=2) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type=self.packing_list_portal_type) @@ -1235,7 +1231,7 @@ class TestInvoice(TestInvoiceMixin): packing_list.start() packing_list.stop() self.assertEquals('stopped', packing_list.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() invoice = packing_list.getCausalityRelatedValue( @@ -1248,7 +1244,7 @@ class TestInvoice(TestInvoiceMixin): new_quantity = invoice_line.getQuantity() * 2 invoice_line.setQuantity(new_quantity) - get_transaction().commit() + transaction.commit() self.tic() self.assertTrue(invoice.isDivergent()) @@ -1265,7 +1261,7 @@ class TestInvoice(TestInvoiceMixin): builder.solveDivergence(invoice.getRelativeUrl(), divergence_to_accept_list=divergence_list) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('solved', invoice.getCausalityState()) @@ -1295,7 +1291,7 @@ class TestInvoice(TestInvoiceMixin): packing_list.start() packing_list.stop() self.assertEquals('stopped', packing_list.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() invoice = packing_list.getCausalityRelatedValue( @@ -1308,7 +1304,7 @@ class TestInvoice(TestInvoiceMixin): new_quantity = invoice_line.getQuantity() * 2 invoice_line.setQuantity(new_quantity) - get_transaction().commit() + transaction.commit() self.tic() self.assertTrue(invoice.isDivergent()) @@ -1325,7 +1321,7 @@ class TestInvoice(TestInvoiceMixin): builder.solveDivergence(invoice.getRelativeUrl(), divergence_to_adopt_list=divergence_list) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals([], invoice.getDivergenceList()) self.assertEquals('solved', invoice.getCausalityState()) @@ -3110,7 +3106,7 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase): packing_list.setReady() packing_list.start() self.assertEquals('started', packing_list.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() invoice = packing_list.getCausalityRelatedValue( @@ -3123,7 +3119,7 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase): new_quantity = invoice_line.getQuantity() * 2 invoice_line.setQuantity(new_quantity) - get_transaction().commit() + transaction.commit() self.tic() self.assertTrue(invoice.isDivergent()) @@ -3140,7 +3136,7 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase): builder.solveDivergence(invoice.getRelativeUrl(), divergence_to_accept_list=divergence_list) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('solved', invoice.getCausalityState()) @@ -3165,7 +3161,7 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase): builder.solveDivergence(packing_list.getRelativeUrl(), divergence_to_adopt_list=divergence_list) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('solved', packing_list.getCausalityState()) self.assertEquals('solved', invoice.getCausalityState()) diff --git a/product/ERP5/tests/testInvoiceVAT.py b/product/ERP5/tests/testInvoiceVAT.py index 9a2317291a..de275f02fc 100644 --- a/product/ERP5/tests/testInvoiceVAT.py +++ b/product/ERP5/tests/testInvoiceVAT.py @@ -32,6 +32,7 @@ Warning: this tests an obsolete API; the test is disabled. """ import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager @@ -63,7 +64,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): def _safeTic(self): """Like tic, but swallowing errors, usefull for teardown""" try: - get_transaction().commit() + transaction.commit() self.tic() except RuntimeError: pass @@ -93,7 +94,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): activity_tool.manageCancel(message.object_path, message.method_id) _print('\nCancelling active message %s.%s()\n' % (message.object_path, message.method_id) ) - get_transaction().commit() + transaction.commit() def login(self, quiet=0, run=1): uf = self.getPortal().acl_users @@ -148,7 +149,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): account = self.getPortal().account_module.newContent( portal_type='Account', **kw) - get_transaction().commit() + transaction.commit() self.tic() return account @@ -157,7 +158,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): org = self.getPortal().organisation_module.newContent( portal_type='Organisation', **kw) - get_transaction().commit() + transaction.commit() self.tic() return org @@ -166,7 +167,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): spl = self.getPortal().sale_packing_list_module.newContent( portal_type='Sale Packing List',) spl.edit(**kw) - get_transaction().commit() + transaction.commit() self.tic() return spl @@ -176,7 +177,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): portal_type='Sale Invoice Transaction', created_by_builder=created_by_builder) sit.edit(**kw) - get_transaction().commit() + transaction.commit() self.tic() return sit @@ -184,7 +185,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): """Creates a currency.""" currency = self.getCurrencyModule().newContent( portal_type = 'Currency', **kw) - get_transaction().commit() + transaction.commit() self.tic() return currency @@ -192,7 +193,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): """Creates a resource.""" resource = self.getPortal().product_module.newContent( portal_type='Product', **kw) - get_transaction().commit() + transaction.commit() self.tic() return resource @@ -214,7 +215,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): pred.setMembershipCriterionBaseCategoryList('resource') pred.setMembershipCriterionCategoryList(['resource/%s' % resource.getRelativeUrl()]) - get_transaction().commit() + transaction.commit() self.tic() itr.updateMatrix() @@ -241,11 +242,11 @@ class TestInvoiceVAT(ERP5TypeTestCase): packing_list.confirm() packing_list.setReady() packing_list.start() - get_transaction().commit() + transaction.commit() self.tic() packing_list.stop() self.assertEquals(packing_list.getSimulationState(), 'stopped') - get_transaction().commit() + transaction.commit() self.tic() def _makeOnePackingList(self): @@ -344,7 +345,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): # confirm the invoice, invoice.confirm() - get_transaction().commit() + transaction.commit() self.tic() # this will generate accounting lines self.assertNotEquals(len(invoice.getMovementList( @@ -373,7 +374,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): price=100, resource_value=resource ) invoice.plan() - get_transaction().commit(); + transaction.commit(); self.tic() # actual values on invoice line should be: @@ -398,7 +399,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): price=100, resource_value=resource ) invoice.plan() - get_transaction().commit(); + transaction.commit(); self.tic() # actual values on invoice line should be: @@ -433,7 +434,7 @@ class TestInvoiceVAT(ERP5TypeTestCase): price=100, resource_value=res ) invoice.plan() - get_transaction().commit(); + transaction.commit(); self.tic() # actual values on invoice line should be: diff --git a/product/ERP5/tests/testNotificationMessageModule.py b/product/ERP5/tests/testNotificationMessageModule.py index 48acba1649..43c636ac55 100644 --- a/product/ERP5/tests/testNotificationMessageModule.py +++ b/product/ERP5/tests/testNotificationMessageModule.py @@ -28,6 +28,7 @@ import unittest +import transaction from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager @@ -75,17 +76,17 @@ class TestNotificationMessageModule(ERP5TypeTestCase): portal._setObject('MailHost', DummyMailHost('MailHost')) portal.email_from_address = 'site@example.invalid' self.portal.portal_caches.clearAllCache() - get_transaction().commit() + transaction.commit() self.tic() self.changeUser('erp5user') def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary module_list = (self.getNotificationMessageModule(),) for module in module_list: module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def test_01_get_document(self, quiet=quiet, run=run_all_test): @@ -102,7 +103,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase): language='en', version='01') n_m_en.validate() - get_transaction().commit() + transaction.commit() self.tic() result = tool.getDocumentValue(reference='A') self.assertEqual(result.getRelativeUrl(), n_m_en.getRelativeUrl()) @@ -112,7 +113,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase): language='fr', version='01') n_m_fr.validate() - get_transaction().commit() + transaction.commit() self.tic() result = tool.getDocumentValue(reference='A', language='fr') self.assertEqual(result.getRelativeUrl(), n_m_fr.getRelativeUrl()) @@ -122,7 +123,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase): language='fr', version='02') n_m_fr_02.validate() - get_transaction().commit() + transaction.commit() self.tic() result = tool.getDocumentValue(reference='A', language='fr') self.assertEqual(result.getRelativeUrl(), n_m_fr_02.getRelativeUrl()) diff --git a/product/ERP5/tests/testNotificationTool.py b/product/ERP5/tests/testNotificationTool.py index acd7d7a08e..4b25f445ad 100644 --- a/product/ERP5/tests/testNotificationTool.py +++ b/product/ERP5/tests/testNotificationTool.py @@ -28,6 +28,7 @@ import unittest +import transaction from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager @@ -134,16 +135,16 @@ class TestNotificationTool(ERP5TypeTestCase): portal._setObject('MailHost', DummyMailHost('MailHost')) portal.email_from_address = 'site@example.invalid' self.portal.portal_caches.clearAllCache() - get_transaction().commit() + transaction.commit() self.tic() self.changeUser('erp5user') def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary self.portal.person_module.manage_delObjects( list(self.portal.person_module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def stepTic(self,**kw): @@ -588,7 +589,7 @@ class TestNotificationToolWithCRM(TestNotificationTool): TestNotificationTool.beforeTearDown(self) self.portal.event_module.manage_delObjects( list(self.portal.event_module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def test_store_as_event(self): @@ -603,7 +604,7 @@ class TestNotificationToolWithCRM(TestNotificationTool): recipient=person, subject='Subject', message='Message') - get_transaction().commit() + transaction.commit() self.tic() last_message = self.portal.MailHost._last_message self.assertNotEquals((), last_message) diff --git a/product/ERP5/tests/testOpenOrder.py b/product/ERP5/tests/testOpenOrder.py index a07c00b585..55a01de46f 100644 --- a/product/ERP5/tests/testOpenOrder.py +++ b/product/ERP5/tests/testOpenOrder.py @@ -25,10 +25,10 @@ # ############################################################################## import unittest -from transaction import get as get_transaction from AccessControl.SecurityManagement import newSecurityManager from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from DateTime import DateTime +import transaction class TestOpenOrder(ERP5TypeTestCase): @@ -170,7 +170,7 @@ class TestOpenOrder(ERP5TypeTestCase): ) self.portal._run_after_setup = True - get_transaction().commit() + transaction.commit() self.tic() def testPeriodicityDateList(self): @@ -244,7 +244,7 @@ class TestOpenOrder(ERP5TypeTestCase): open_sale_order.Order_applyTradeCondition(open_sale_order.getSpecialiseValue()) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(open_sale_order_line.getPrice(), 100) @@ -255,7 +255,7 @@ class TestOpenOrder(ERP5TypeTestCase): open_sale_order.order() open_sale_order.start() - get_transaction().commit() + transaction.commit() self.tic() applied_rule = open_sale_order.getCausalityRelatedValue(portal_type='Applied Rule') @@ -265,7 +265,7 @@ class TestOpenOrder(ERP5TypeTestCase): applied_rule, calculation_base_date=DateTime(3000,2,9)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 1) @@ -277,7 +277,7 @@ class TestOpenOrder(ERP5TypeTestCase): applied_rule, calculation_base_date=DateTime(3000,2,9)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 2) @@ -288,7 +288,7 @@ class TestOpenOrder(ERP5TypeTestCase): applied_rule, calculation_base_date=DateTime(3000,3,1)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 5) @@ -305,7 +305,7 @@ class TestOpenOrder(ERP5TypeTestCase): applied_rule, calculation_base_date=DateTime(3000,3,1)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 5) @@ -315,7 +315,7 @@ class TestOpenOrder(ERP5TypeTestCase): applied_rule, calculation_base_date=DateTime(3000,3,30)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 6) @@ -344,7 +344,7 @@ class TestOpenOrder(ERP5TypeTestCase): # Remove other test's side effect. self.portal.sale_trade_condition_module.main_trade_condition.setExpirationDate(None) - get_transaction().commit() + transaction.commit() self.tic() open_sale_order.newContent( @@ -373,13 +373,13 @@ class TestOpenOrder(ERP5TypeTestCase): open_sale_order.Order_applyTradeCondition(open_sale_order.getSpecialiseValue()) - get_transaction().commit() + transaction.commit() self.tic() open_sale_order.order() open_sale_order.start() - get_transaction().commit() + transaction.commit() self.tic() applied_rule = open_sale_order.getCausalityRelatedValue(portal_type='Applied Rule') @@ -387,7 +387,7 @@ class TestOpenOrder(ERP5TypeTestCase): open_sale_order.autoOrderPeriodically(comment='Test', calculation_base_date=DateTime(3000,2,9)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 9) @@ -396,7 +396,7 @@ class TestOpenOrder(ERP5TypeTestCase): # Do the same thing and nothing happens. open_sale_order.autoOrderPeriodically(comment='Test', calculation_base_date=DateTime(3000,2,9)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 9) @@ -405,7 +405,7 @@ class TestOpenOrder(ERP5TypeTestCase): # Next open_sale_order.autoOrderPeriodically(comment='Test', calculation_base_date=DateTime(3000,2,14)) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(applied_rule.objectIds()), 19) diff --git a/product/ERP5/tests/testOrder.py b/product/ERP5/tests/testOrder.py index f086c81e4e..dad7726d38 100644 --- a/product/ERP5/tests/testOrder.py +++ b/product/ERP5/tests/testOrder.py @@ -30,6 +30,7 @@ import unittest import os +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.utils import FileUpload from AccessControl.SecurityManagement import newSecurityManager @@ -2053,7 +2054,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): resource_value=resource, price=2, quantity=3) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), True) @@ -2079,7 +2080,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): price=3, quantity=4, predicate_category_list=cell_key, variation_category_list=cell_key) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), False) @@ -2101,7 +2102,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): # if cell has no price, the total price is None, but a default value can be # provided cell.setPrice(None) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), False) @@ -2122,7 +2123,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): # restore the price on the line cell.setPrice(3) - get_transaction().commit() + transaction.commit() self.tic() # add sub_line to line, cell and line are not movements @@ -2130,7 +2131,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): portal_type=self.order_line_portal_type, price=4, quantity=5) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), False) @@ -2157,7 +2158,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): # if this line has no price, getTotalPrice returns 0 sub_order_line.setPrice(None) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), False) self.assertEquals(cell.isMovement(), False) @@ -2183,7 +2184,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): # restore price on the sub line sub_order_line.setPrice(4) - get_transaction().commit() + transaction.commit() self.tic() @@ -2198,7 +2199,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): price=5, quantity=6, predicate_category_list=cell_key, variation_category_list=cell_key) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), False) @@ -2229,7 +2230,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): # delete sub_line, cell is movement again order_line.manage_delObjects([sub_order_line.getId()]) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), False) @@ -2251,7 +2252,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): # delete cell, line is movement again order_line.manage_delObjects([cell.getId()]) order_line.setVariationCategoryList([]) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(order_line.isMovement(), True) @@ -2447,7 +2448,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): portal_type='Payment Condition'))) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() related_packing_list = order.getCausalityRelatedValue( portal_type=self.packing_list_portal_type) @@ -2477,7 +2478,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): quantity=10, price=3) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = order.Order_viewAsODT() @@ -2509,7 +2510,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): quantity=10, price=3) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = order.Order_viewAsODT() @@ -2546,7 +2547,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): quantity=10, price=3) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = order.Order_viewAsODT() @@ -2586,7 +2587,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): quantity=10, price=3) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = order.Order_viewAsODT() @@ -2628,7 +2629,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): quantity=30, price=.26) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = order.Order_viewAsODT() @@ -2667,7 +2668,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): quantity=10, price=3) order.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = order.Order_viewAsODT() diff --git a/product/ERP5/tests/testOrderBuilder.py b/product/ERP5/tests/testOrderBuilder.py index bd8888b10c..97f59d0f00 100644 --- a/product/ERP5/tests/testOrderBuilder.py +++ b/product/ERP5/tests/testOrderBuilder.py @@ -29,6 +29,7 @@ import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from DateTime import DateTime from zLOG import LOG @@ -312,7 +313,7 @@ class TestOrderBuilderMixin(TestOrderMixin): list(self.decrease_quantity_matrix.iterkeys()) ) - get_transaction().commit() + transaction.commit() self.tic() base_id = 'movement' diff --git a/product/ERP5/tests/testPackingList.py b/product/ERP5/tests/testPackingList.py index 416e170c6d..5fe50ca19c 100644 --- a/product/ERP5/tests/testPackingList.py +++ b/product/ERP5/tests/testPackingList.py @@ -28,6 +28,8 @@ import unittest +import transaction + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from zLOG import LOG from Products.ERP5Type.tests.Sequence import SequenceList @@ -846,7 +848,7 @@ class TestPackingListMixin(TestOrderMixin): """ if packing_list is None: packing_list = sequence.get('packing_list') - get_transaction().commit() + transaction.commit() self.assertEquals(1,packing_list.isPacked()) self.assertEquals('packed',packing_list.getContainerState()) @@ -1338,7 +1340,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : quantity=10, price=3) packing_list.confirm() - get_transaction().commit() + transaction.commit() self.tic() odt = packing_list.PackingList_viewAsODT() diff --git a/product/ERP5/tests/testPasswordTool.py b/product/ERP5/tests/testPasswordTool.py index d73cb9c922..29af5dea33 100644 --- a/product/ERP5/tests/testPasswordTool.py +++ b/product/ERP5/tests/testPasswordTool.py @@ -60,16 +60,16 @@ class TestPasswordTool(ERP5TypeTestCase): self.portal.portal_caches.clearAllCache() def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary self.portal.person_module.manage_delObjects(list(self.portal.person_module.objectIds())) # reset password tool internal structure self.portal.portal_password.password_request_dict.clear() - get_transaction().commit() + transaction.commit() self.tic() def stepTic(self,**kw): - get_transaction().commit() + transaction.commit() self.tic() def getUserFolder(self): diff --git a/product/ERP5/tests/testProductionOrder.py b/product/ERP5/tests/testProductionOrder.py index 32b55764a6..7d785cd12d 100644 --- a/product/ERP5/tests/testProductionOrder.py +++ b/product/ERP5/tests/testProductionOrder.py @@ -30,6 +30,8 @@ import unittest +import transaction + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from zLOG import LOG from Products.ERP5Type.tests.Sequence import SequenceList @@ -85,7 +87,7 @@ class TestProductionOrderMixin(TestOrderMixin): ) system_preference.enable() - get_transaction().commit() + transaction.commit() self.tic() def afterSetUp(self): diff --git a/product/ERP5/tests/testQueryModule.py b/product/ERP5/tests/testQueryModule.py index 809404b4eb..c4a3c29cb8 100644 --- a/product/ERP5/tests/testQueryModule.py +++ b/product/ERP5/tests/testQueryModule.py @@ -29,6 +29,7 @@ import unittest import os from AccessControl.SecurityManagement import newSecurityManager +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.utils import DummyMailHost @@ -48,11 +49,11 @@ class TestQueryModule(ERP5TypeTestCase): portal._setObject('MailHost', DummyMailHost('MailHost')) def beforeTearDown(self): - get_transaction().abort() + transaction.abort() # clear modules if necessary for module in (self.portal.person_module, self.portal.query_module,): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def test_post_query_action_visible(self): @@ -99,7 +100,7 @@ class TestQueryModule(ERP5TypeTestCase): default_email_text='question_user@example.invalid') assignment = question_person.newContent(portal_type='Assignment') assignment.validate() - get_transaction().commit() + transaction.commit() self.tic() uf = self.portal.acl_users owner_user = uf.getUser('owner_user').__of__(uf) diff --git a/product/ERP5/tests/testRSS.py b/product/ERP5/tests/testRSS.py index 379c193be8..9b451e4c9d 100644 --- a/product/ERP5/tests/testRSS.py +++ b/product/ERP5/tests/testRSS.py @@ -33,10 +33,7 @@ from Products.ERP5Form.Form import ERP5Form from xml.dom.minidom import parseString -try: - from transaction import get as get_transaction -except ImportError: - pass +import transaction def getNodeContent(node): @@ -82,7 +79,7 @@ class TestRSS(ERP5TypeTestCase): self.portal.person_module.manage_delObjects(['two']) one = self.portal.person_module.newContent(id="one", title="One", description="Person One") two = self.portal.person_module.newContent(id="two", title="Two", description="Person Two") - get_transaction().commit() + transaction.commit() one.reindexObject() two.reindexObject() self.tic() diff --git a/product/ERP5/tests/testResource.py b/product/ERP5/tests/testResource.py index 59b3c2a07b..3d57430726 100644 --- a/product/ERP5/tests/testResource.py +++ b/product/ERP5/tests/testResource.py @@ -27,7 +27,7 @@ ############################################################################## import unittest - +import transaction from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager @@ -79,7 +79,7 @@ class TestResource(ERP5TypeTestCase): self.createCategories() def beforeTearDown(self): - get_transaction().abort() + transaction.abort() for folder in ( self.portal.getDefaultModule(self.resource_portal_type), self.portal.getDefaultModule(self.sale_supply_portal_type), @@ -88,7 +88,7 @@ class TestResource(ERP5TypeTestCase): self.portal.getDefaultModule("Sale Order"), self.portal.getDefaultModule("Purchase Order"),): folder.manage_delObjects([i for i in folder.objectIds()]) - get_transaction().commit() + transaction.commit() self.tic() def createCategories(self): @@ -579,7 +579,7 @@ class TestResource(ERP5TypeTestCase): supply_line.setProperty(key, pricing_param) # Commit transaction self.logMessage("Commit transaction...", tab=1) - get_transaction().commit() + transaction.commit() # Tic self.logMessage("Tic...", tab=1) self.tic() @@ -598,7 +598,7 @@ class TestResource(ERP5TypeTestCase): preference = self.portal.portal_preferences.default_site_preference preference.setPreferredProductOptionalVariationBaseCategoryList(['industrial_phase']) preference.enable() - get_transaction().commit() + transaction.commit() self.tic() # Create another product/supply, in order to be sure that the # nothing will be generated from this supply! @@ -654,7 +654,7 @@ class TestResource(ERP5TypeTestCase): cell2.setMembershipCriterionCategory('industrial_phase/phase2') # Commit transaction self.logMessage("Commit transaction...", tab=1) - get_transaction().commit() + transaction.commit() # Tic self.logMessage("Tic...", tab=1) self.tic() @@ -738,7 +738,7 @@ class TestResource(ERP5TypeTestCase): test_case_list.append((product, None, j)) # Commit transaction self.logMessage("Commit transaction...", tab=1) - get_transaction().commit() + transaction.commit() # Tic self.logMessage("Tic...", tab=1) self.tic() @@ -857,7 +857,7 @@ class TestResource(ERP5TypeTestCase): # Commit transaction self.logMessage("Commit transaction...", tab=1) - get_transaction().commit() + transaction.commit() # Tic self.logMessage("Tic...", tab=1) self.tic() @@ -937,11 +937,11 @@ class TestResource(ERP5TypeTestCase): sale_order_line = sale_order.newContent( portal_type="Sale Order Line", resource_value=product) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(sale_order_line.getPrice(), 400.0) sale_order.setDestinationSectionValue(orga2) - get_transaction().commit() + transaction.commit() self.tic() sale_order_line.setPrice(None) self.assertEquals(sale_order_line.getPrice(), 200.0) @@ -953,11 +953,11 @@ class TestResource(ERP5TypeTestCase): purchase_order_line = purchase_order.newContent( portal_type="Purchase Order Line", resource_value=product) - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(purchase_order_line.getPrice(), 40.0) purchase_order.setSourceSectionValue(orga2) - get_transaction().commit() + transaction.commit() self.tic() purchase_order_line.setPrice(None) self.assertEquals(purchase_order_line.getPrice(), 20.0) @@ -969,7 +969,7 @@ class TestResource(ERP5TypeTestCase): supply_line = resource.newContent( portal_type=self.sale_supply_line_portal_type) supply_line.setBasePrice(1000) - get_transaction().commit() + transaction.commit() self.tic() sale_order = self.portal.getDefaultModule("Sale Order").newContent( portal_type='Sale Order',) diff --git a/product/ERP5/tests/testResourceVariation.py b/product/ERP5/tests/testResourceVariation.py index d691d5f03e..ab1686f9bc 100644 --- a/product/ERP5/tests/testResourceVariation.py +++ b/product/ERP5/tests/testResourceVariation.py @@ -32,6 +32,7 @@ Tests Resource Variations """ import unittest +import transaction from Testing import ZopeTestCase from zLOG import LOG from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -222,13 +223,13 @@ class ResourceVariationTestCase(ERP5TypeTestCase): 'option_colour', 'individual_aspect'] - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): """Remove all documents. """ - get_transaction().abort() + transaction.abort() self.product_module.manage_delObjects( list(self.service_module.objectIds())) self.service_module.manage_delObjects( @@ -238,7 +239,7 @@ class ResourceVariationTestCase(ERP5TypeTestCase): self.portal_categories.manage_delObjects((['required_size', 'individual_aspect','option_colour'])) - get_transaction().commit() + transaction.commit() self.tic() def getBusinessTemplateList(self): diff --git a/product/ERP5/tests/testRule.py b/product/ERP5/tests/testRule.py index 3ed73f34e5..44977747fb 100644 --- a/product/ERP5/tests/testRule.py +++ b/product/ERP5/tests/testRule.py @@ -27,6 +27,8 @@ import unittest +import transaction + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.utils import createZODBPythonScript from zLOG import LOG @@ -65,7 +67,7 @@ class TestRuleMixin(TestOrderMixin): self.getSimulationTool().manage_delObjects( ids=list(self.getSimulationTool().objectIds())) # commit - get_transaction().commit() + transaction.commit() self.tic() @@ -74,7 +76,7 @@ class TestRuleMixin(TestOrderMixin): container.manage_delObjects(ids=[id]) self.getSimulationTool().manage_delObjects( ids=list(self.getSimulationTool().objectIds())) - get_transaction().commit() + transaction.commit() self.tic() def getTitle(self): @@ -96,10 +98,10 @@ class TestRuleMixin(TestOrderMixin): source_section='group/a', destination_section='group/b') pl.newContent(portal_type=self.packing_list_line_portal_type, id='line') pl.setStartDate("2007-07-01") - get_transaction().commit() + transaction.commit() self.tic() pl.confirm() - get_transaction().commit() + transaction.commit() self.tic() return pl @@ -118,7 +120,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : delivery_rule = self.getRuleTool().searchFolder( reference='default_delivery_rule')[0] delivery_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.getRuleTool().countFolder( @@ -138,7 +140,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : reference='default_delivery_rule')[0] delivery_rule.setTestMethodId('wrong_script') delivery_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.getRuleTool().countFolder( @@ -158,7 +160,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : reference='default_delivery_rule')[0] delivery_rule.setTestMethodId('good_script') delivery_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.getRuleTool().countFolder( @@ -180,7 +182,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : delivery_rule.setTestMethodId('good_script') delivery_rule.validate() delivery_rule.invalidate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.getRuleTool().countFolder( @@ -200,7 +202,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : reference='default_delivery_rule')[0] delivery_rule.setTestMethodId('good_script') delivery_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.getRuleTool().countFolder( @@ -223,7 +225,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : delivery_rule.setStartDateRangeMin('2007-06-01') delivery_rule.setStartDateRangeMax('2007-06-04') delivery_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.getRuleTool().countFolder( @@ -246,7 +248,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : delivery_rule.setStartDateRangeMin('2007-06-01') delivery_rule.setStartDateRangeMax('2007-08-01') delivery_rule.validate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.getRuleTool().countFolder( @@ -282,12 +284,12 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : version='2') delivery_rule_2.setTestMethodId('rule_script') delivery_rule_2.validate() - get_transaction().commit() + transaction.commit() self.tic() # delivery_rule_2 should be applied self.pl.updateAppliedRule('default_delivery_rule') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.pl.getCausalityRelatedValue().getSpecialise(), delivery_rule_2.getRelativeUrl()) @@ -297,12 +299,12 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # increase version of delivery_rule_1 delivery_rule_1.setVersion("3") - get_transaction().commit() + transaction.commit() self.tic() # delivery_rule_1 should be applied self.pl.updateAppliedRule('default_delivery_rule') - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(self.pl.getCausalityRelatedValue().getSpecialise(), delivery_rule_1.getRelativeUrl()) @@ -344,11 +346,11 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # clear simulation self.getSimulationTool().manage_delObjects( ids=list(self.getSimulationTool().objectIds())) - get_transaction().commit() + transaction.commit() self.tic() self.pl.updateAppliedRule('default_delivery_rule') - get_transaction().commit() + transaction.commit() self.tic() # check that only one invoicing rule (higher version) was applied @@ -367,11 +369,11 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : self.getSimulationTool().manage_delObjects( ids=[self.pl.getCausalityRelatedId()]) invoicing_rule_1.setVersion('3') - get_transaction().commit() + transaction.commit() self.tic() self.pl.updateAppliedRule('default_delivery_rule') - get_transaction().commit() + transaction.commit() self.tic() # check that only one invoicing rule (higher version) was applied @@ -418,11 +420,11 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # clear simulation self.getSimulationTool().manage_delObjects( ids=list(self.getSimulationTool().objectIds())) - get_transaction().commit() + transaction.commit() self.tic() self.pl.updateAppliedRule('default_delivery_rule') - get_transaction().commit() + transaction.commit() self.tic() root_applied_rule = self.pl.getCausalityRelatedValue() @@ -436,7 +438,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # change rule script so that it matches and test again invoicing_rule_1.setTestMethodId('invoice_rule_script') root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), @@ -464,10 +466,10 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : portal_type="Invoicing Rule", reference='default_invoicing_rule_2', version='2', test_method_id='invoice_rule_script') invoicing_rule_n.validate() - get_transaction().commit() + transaction.commit() self.tic() root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), @@ -516,11 +518,11 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : self.getSimulationTool().manage_delObjects( ids=list(self.getSimulationTool().objectIds())) - get_transaction().commit() + transaction.commit() self.tic() self.pl.updateAppliedRule('default_delivery_rule') - get_transaction().commit() + transaction.commit() self.tic() root_applied_rule = self.pl.getCausalityRelatedValue() @@ -536,11 +538,11 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # invalidate the rule and test that it is still there invoicing_rule_1.invalidate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(invoicing_rule_1.getValidationState(), 'invalidated') root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), @@ -558,7 +560,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # removed invoicing_rule_1.setTestMethodId('delivery_rule_script') root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), @@ -574,11 +576,11 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # that the rule is still there invoicing_rule_1.setTestMethodId('invoice_rule_script') invoicing_rule_1.validate() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(invoicing_rule_1.getValidationState(), 'validated') root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), @@ -598,7 +600,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : invoicing_rule_1.setTestMethodId('delivery_rule_script') root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), @@ -653,11 +655,11 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : self.getSimulationTool().manage_delObjects( ids=list(self.getSimulationTool().objectIds())) - get_transaction().commit() + transaction.commit() self.tic() self.pl.updateAppliedRule('default_delivery_rule') - get_transaction().commit() + transaction.commit() self.tic() root_applied_rule = self.pl.getCausalityRelatedValue() @@ -675,7 +677,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : # replaced by invoicing rule 1 invoicing_rule_2.setTestMethodId('delivery_rule_script') root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), @@ -695,7 +697,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : sub_movement = applied_rule.objectValues()[0] sub_movement.setDeliveryValue(self.pl.line) root_applied_rule.expand() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals(root_applied_rule.getRelativeUrl(), diff --git a/product/ERP5/tests/testSupply.py b/product/ERP5/tests/testSupply.py index 4b7ee0107f..eb34496771 100644 --- a/product/ERP5/tests/testSupply.py +++ b/product/ERP5/tests/testSupply.py @@ -28,6 +28,7 @@ import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.utils import reindex from DateTime import DateTime @@ -105,7 +106,7 @@ class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase): start_date_range_max='2009/01/31') supply_line = self._makeSupplyLine(supply) - get_transaction().commit() + transaction.commit() self.tic() res = self.domain_tool.searchPredicateList(movement, @@ -118,7 +119,7 @@ class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase): supply.edit(start_date_range_min='2009/02/01', start_date_range_max='2009/02/28') - get_transaction().commit() + transaction.commit() self.tic() res = self.domain_tool.searchPredicateList(movement, @@ -130,7 +131,7 @@ class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase): # movement is going back into timeframe... movement.edit(start_date='2009/02/15') - get_transaction().commit() + transaction.commit() self.tic() res = self.domain_tool.searchPredicateList(movement, @@ -166,7 +167,7 @@ class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase): # set new date on supply... supply.edit(start_date_range_min=new_date) - get_transaction().commit() + transaction.commit() self.tic() # ...and check supply line diff --git a/product/ERP5/tests/testTemplate.py b/product/ERP5/tests/testTemplate.py index 5405647b83..87c6f91365 100644 --- a/product/ERP5/tests/testTemplate.py +++ b/product/ERP5/tests/testTemplate.py @@ -28,6 +28,7 @@ """Tests Template functionality""" import unittest +import transaction from AccessControl.SecurityManagement import newSecurityManager from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type import Permissions @@ -67,19 +68,19 @@ class TestTemplate(ERP5TypeTestCase): preference.priority = Priority.USER preference.enable() - get_transaction().commit() + transaction.commit() self.tic() document = self.portal.foo_module.newContent(portal_type='Foo') document.edit(title='My Foo 1') document.newContent(portal_type='Foo Line') - get_transaction().commit() + transaction.commit() self.tic() document.Base_makeTemplateFromDocument(form_id=None) - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(len(preference.objectIds()), 1) @@ -90,7 +91,7 @@ class TestTemplate(ERP5TypeTestCase): self.portal.foo_module.manage_delObjects(ids=[document.getId()]) - get_transaction().commit() + transaction.commit() self.tic() template = preference.objectValues()[0] @@ -101,7 +102,7 @@ class TestTemplate(ERP5TypeTestCase): new_document = self.portal.foo_module[new_document_id] new_document.makeTemplateInstance() - get_transaction().commit() + transaction.commit() self.tic() self.assertEqual(new_document.getTitle(), 'My Foo 1') @@ -116,11 +117,11 @@ class TestTemplate(ERP5TypeTestCase): preference_id_list = list(self.portal.portal_preferences.objectIds()) document = self.portal.foo_module.newContent(portal_type='Foo') - get_transaction().commit() + transaction.commit() self.tic() document.Base_makeTemplateFromDocument(form_id=None) - get_transaction().commit() + transaction.commit() self.tic() # a new preference is created @@ -145,18 +146,18 @@ class TestTemplate(ERP5TypeTestCase): preference.priority = Priority.USER preference.enable() - get_transaction().commit() + transaction.commit() self.tic() document = self.portal.foo_module.newContent(portal_type='Foo') document.edit(title='My Foo 1') document.newContent(portal_type='Foo Line') - get_transaction().commit() + transaction.commit() self.tic() document.Base_makeTemplateFromDocument(form_id=None) - get_transaction().commit() + transaction.commit() self.tic() self.assertTrue(document.isIndexable) self.assertEqual(len(preference.objectIds()), 1) @@ -166,7 +167,7 @@ class TestTemplate(ERP5TypeTestCase): # and this is still true if you create two templates from the same document # #929 document.Base_makeTemplateFromDocument(form_id=None) - get_transaction().commit() + transaction.commit() self.tic() self.assertTrue(document.isIndexable) diff --git a/product/ERP5/tests/testTradeCondition.py b/product/ERP5/tests/testTradeCondition.py index 3094785c20..1404f49e64 100644 --- a/product/ERP5/tests/testTradeCondition.py +++ b/product/ERP5/tests/testTradeCondition.py @@ -33,11 +33,6 @@ from DateTime import DateTime from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase -try: - from transaction import get as get_transaction -except ImportError: - pass - class TradeConditionTestCase(ERP5TypeTestCase): """Tests for Trade Conditions and Tax """ @@ -82,7 +77,7 @@ class TradeConditionTestCase(ERP5TypeTestCase): title='Order') def beforeTearDown(self): - get_transaction().abort() + transaction.abort() for module in (self.portal.tax_module, self.portal.organisation_module, self.portal.currency_module, @@ -96,7 +91,7 @@ class TradeConditionTestCase(ERP5TypeTestCase): self.portal.portal_categories.size, ): module.manage_delObjects(list(module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() @@ -154,7 +149,7 @@ class AccountingBuildTestCase(TradeConditionTestCase): title='Resource Tax', int_index=2, test_method_id='SimulationMovement_isTaxMovement' ) - get_transaction().commit() + transaction.commit() self.tic() accounting_rule_cell_list = itr.contentValues( portal_type='Accounting Rule Cell') @@ -185,13 +180,13 @@ class AccountingBuildTestCase(TradeConditionTestCase): destination_value=self.refundable_tax_account, quantity=1) itr.validate() - get_transaction().commit() + transaction.commit() self.tic() def beforeTearDown(self): TradeConditionTestCase.beforeTearDown(self) self.portal.portal_rules.manage_delObjects('test_invoice_transaction_rule') - get_transaction().commit() + transaction.commit() self.tic() class TestApplyTradeCondition(TradeConditionTestCase): @@ -1121,7 +1116,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): order.plan() order.confirm() self.assertEquals('confirmed', order.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule_list = order.getCausalityRelatedValueList( portal_type='Applied Rule') @@ -1206,7 +1201,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): order.plan() order.confirm() self.assertEquals('confirmed', order.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule_list = order.getCausalityRelatedValueList( portal_type='Applied Rule') @@ -1280,7 +1275,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): order.plan() order.confirm() self.assertEquals('confirmed', order.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_delivery = order.getCausalityRelatedValue( portal_type=('Purchase Packing List', 'Sale Packing List')) @@ -1290,7 +1285,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): related_delivery.stop() related_delivery.deliver() self.assertEquals('delivered', related_delivery.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_delivery.getCausalityRelatedValue( @@ -1351,7 +1346,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): order.plan() order.confirm() self.assertEquals('confirmed', order.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_delivery = order.getCausalityRelatedValue( portal_type=('Purchase Packing List', 'Sale Packing List')) @@ -1361,7 +1356,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): related_delivery.stop() related_delivery.deliver() self.assertEquals('delivered', related_delivery.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_delivery.getCausalityRelatedValue( @@ -1375,7 +1370,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): self.assertEquals(0, len(accounting_line_list)) related_invoice.start() - get_transaction().commit() + transaction.commit() self.tic() self.assertEquals('started', related_invoice.getSimulationState()) self.assertEquals('solved', related_invoice.getCausalityState()) @@ -1457,7 +1452,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): order.plan() order.confirm() self.assertEquals('confirmed', order.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_delivery = order.getCausalityRelatedValue( portal_type=('Purchase Packing List', 'Sale Packing List')) @@ -1467,7 +1462,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): related_delivery.stop() related_delivery.deliver() self.assertEquals('delivered', related_delivery.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_delivery.getCausalityRelatedValue( @@ -1519,7 +1514,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): order.plan() order.confirm() self.assertEquals('confirmed', order.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_delivery = order.getCausalityRelatedValue( portal_type=('Purchase Packing List', 'Sale Packing List')) @@ -1529,7 +1524,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): related_delivery.stop() related_delivery.deliver() self.assertEquals('delivered', related_delivery.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_invoice = related_delivery.getCausalityRelatedValue( @@ -1554,7 +1549,7 @@ class TestTaxLineOrderSimulation(AccountingBuildTestCase): invoice_line = invoice_line_list[0] # change a total price on the invoice_line, invoice_line.setQuantity(3) - get_transaction().commit() + transaction.commit() self.tic() # it will be reflected on the tax line self.assertEquals(45, tax_line.getQuantity()) @@ -1599,7 +1594,7 @@ class TestTaxLineInvoiceSimulation(AccountingBuildTestCase): invoice.confirm() invoice.start() self.assertEquals('started', invoice.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() related_applied_rule_list = invoice.getCausalityRelatedValueList( portal_type='Applied Rule') @@ -1633,7 +1628,7 @@ class TestTaxLineInvoiceSimulation(AccountingBuildTestCase): invoice_simulation_movement.getResourceValue()) invoice.start() self.assertEquals('started', invoice.getSimulationState()) - get_transaction().commit() + transaction.commit() self.tic() accounting_line_list = invoice.getMovementList( portal_type=('Sale Invoice Transaction Line', @@ -1705,7 +1700,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase): base_price=123) self.order.setSpecialiseValue(self.trade_condition) - get_transaction().commit() + transaction.commit() self.tic() line = self.order.newContent(portal_type=self.order_line_type, @@ -1731,7 +1726,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase): self.order.setSpecialiseValue(self.trade_condition) self.order.setSourceSectionValue(self.vendor) self.order.setDestinationSectionValue(self.vendor) - get_transaction().commit() + transaction.commit() self.tic() line = self.order.newContent(portal_type=self.order_line_type, @@ -1765,7 +1760,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase): self.order.setSourceSectionValue(self.vendor) self.order.setDestinationSectionValue(self.client) - get_transaction().commit() + transaction.commit() self.tic() line = self.order.newContent(portal_type=self.order_line_type, diff --git a/product/ERP5/tests/testTradeReports.py b/product/ERP5/tests/testTradeReports.py index c262e142e0..0affcf20a2 100644 --- a/product/ERP5/tests/testTradeReports.py +++ b/product/ERP5/tests/testTradeReports.py @@ -29,6 +29,7 @@ """Tests Standards ERP5 Trade Reports """ import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase from Products.ERP5Type.tests.utils import reindex from AccessControl.SecurityManagement import newSecurityManager @@ -158,14 +159,14 @@ class TestTradeReports(ERP5ReportTestCase): ) # and all this available to catalog - get_transaction().commit() + transaction.commit() self.tic() self.loginAsUser() def beforeTearDown(self): """Remove all documents. """ - get_transaction().abort() + transaction.abort() self.organisation_module.manage_delObjects( list(self.organisation_module.objectIds())) @@ -180,7 +181,7 @@ class TestTradeReports(ERP5ReportTestCase): self.sale_order_module.manage_delObjects( list(self.sale_order_module.objectIds())) - get_transaction().commit() + transaction.commit() self.tic() @reindex @@ -273,7 +274,7 @@ class TestTradeReports(ERP5ReportTestCase): cancel=True ) - get_transaction().commit() + transaction.commit() self.tic() @@ -688,7 +689,7 @@ class TestTradeReports(ERP5ReportTestCase): quantity=11, ) - get_transaction().commit() + transaction.commit() self.tic() request = self.portal.REQUEST @@ -847,7 +848,7 @@ class TestTradeReports(ERP5ReportTestCase): quantity=11, ) - get_transaction().commit() + transaction.commit() self.tic() request = self.portal.REQUEST diff --git a/product/ERP5/tests/testTransformation.py b/product/ERP5/tests/testTransformation.py index e310d98f3b..e0ae9216c9 100644 --- a/product/ERP5/tests/testTransformation.py +++ b/product/ERP5/tests/testTransformation.py @@ -33,6 +33,7 @@ from random import randint +import transaction import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) @@ -111,7 +112,7 @@ class TestTransformation(TestOrderMixin, ERP5TypeTestCase): variations = [variation1, variation2] # Commit and catalog - get_transaction().commit() + transaction.commit() self.tic() component.setVariationBaseCategoryList(['variation']) diff --git a/product/ERP5/tests/testWorklist.py b/product/ERP5/tests/testWorklist.py index e49a857c19..bd1e0913f7 100644 --- a/product/ERP5/tests/testWorklist.py +++ b/product/ERP5/tests/testWorklist.py @@ -29,6 +29,7 @@ import unittest +import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager from Products.ERP5Type.tests.Sequence import SequenceList @@ -111,7 +112,7 @@ class TestWorklist(ERP5TypeTestCase): ) assignment.open() # Reindexing is required for the security to work - get_transaction().commit() + transaction.commit() self.tic() def createUsers(self): @@ -215,7 +216,7 @@ class TestWorklist(ERP5TypeTestCase): self.logMessage("Create document as Manager") document = self.createDocument() - get_transaction().commit() + transaction.commit() self.tic() self.clearCache() @@ -242,7 +243,7 @@ class TestWorklist(ERP5TypeTestCase): self.logMessage("Give %s %s role" % (user_id, role)) document.manage_addLocalRoles(user_id, [role]) document.reindexObject() - get_transaction().commit() + transaction.commit() self.tic() self.clearCache() @@ -269,7 +270,7 @@ class TestWorklist(ERP5TypeTestCase): # Change int value on document new_value = self.int_value + 1 document.setProperty(self.int_catalogued_variable_id, new_value) - get_transaction().commit() + transaction.commit() self.tic() self.clearCache() @@ -306,7 +307,7 @@ class TestWorklist(ERP5TypeTestCase): for i, count in enumerate(count_list): document.manage_permission('View', local_role_list[:i], 0) document.reindexObject() - get_transaction().commit() + transaction.commit() self.tic() self.clearCache() @@ -321,7 +322,7 @@ class TestWorklist(ERP5TypeTestCase): current_sql_catalog_local_role_keys = \ sql_catalog.sql_catalog_local_role_keys sql_catalog.sql_catalog_local_role_keys = ('Owner | owner', ) - get_transaction().commit() + transaction.commit() self.portal.portal_caches.clearAllCache() try: @@ -329,7 +330,7 @@ class TestWorklist(ERP5TypeTestCase): finally: sql_catalog.sql_catalog_local_role_keys = \ current_sql_catalog_local_role_keys - get_transaction().commit() + transaction.commit() def test_02_related_key(self, quiet=0, run=run_all_test): """ @@ -360,7 +361,7 @@ class TestWorklist(ERP5TypeTestCase): base_category_id='role') document = self.createDocument() - get_transaction().commit() + transaction.commit() self.tic() self.clearCache() self.logMessage(" Check no document has region/role categories defined") @@ -373,7 +374,7 @@ class TestWorklist(ERP5TypeTestCase): self.createDocument(region='somewhere') self.createDocument(region='elsewhere') - get_transaction().commit() + transaction.commit() self.tic() self.clearCache() self.logMessage( diff --git a/product/ERP5/tests/testXHTML.py b/product/ERP5/tests/testXHTML.py index 4ee0d53bbc..afbdee4b91 100644 --- a/product/ERP5/tests/testXHTML.py +++ b/product/ERP5/tests/testXHTML.py @@ -40,11 +40,6 @@ from xml.dom import minidom from glob import glob -try: - from transaction import get as get_transaction -except ImportError: - pass - # # Test Setting # -- GitLab