From 4502047009fe8ff2686b27662989426206decb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Thu, 2 Feb 2012 18:45:26 +0100 Subject: [PATCH] Use invoice to represent negative balance. --- .../testVifibSlapComputerPartitionLock.py | 82 +++++++++---------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/master/product/Vifib/tests/testVifibSlapComputerPartitionLock.py b/master/product/Vifib/tests/testVifibSlapComputerPartitionLock.py index 6bac43aa36..f0b24aafbb 100644 --- a/master/product/Vifib/tests/testVifibSlapComputerPartitionLock.py +++ b/master/product/Vifib/tests/testVifibSlapComputerPartitionLock.py @@ -234,6 +234,18 @@ class TestVifibSlapComputerPartitionLock(TestVifibSlapWebServiceMixin): def stepStartInvoice(self, sequence, **kw): sequence['invoice'].start() + def stepCheckWebUserBalanceHighAmount(self, sequence, **kw): + person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[ + 'web_user']) + self.assertEqual(-10000.0, + self.portal.portal_simulation.getInventoryAssetPrice( + node_category='account_type/asset/receivable', + simulation_state=['started', 'stopped', 'delivered'], + section_uid=self.portal.restrictedTraverse( + 'organisation_module/vifib_internet').getUid(), + mirror_section_uid=person.getUid()) + ) + def stepCheckWebUserBalanceSmallAmount(self, sequence, **kw): person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[ 'web_user']) @@ -352,31 +364,26 @@ class TestVifibSlapComputerPartitionLock(TestVifibSlapWebServiceMixin): sequence_list.addSequenceString(sequence_string) sequence_list.play(self) - def stepCreateHighBalanceNotPaidPayment(self, sequence, **kw): + def stepCreateHighBalanceInvoiceWebUser(self, sequence, **kw): person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[ 'web_user']) - payment_transaction = self.portal.accounting_module.newContent( - source_section='organisation_module/vifib_internet', - destination_section=person.getRelativeUrl(), - resource='currency_module/EUR', - portal_type="Payment Transaction", - start_date=DateTime(), - # XXX More info needed - ) - payment_transaction.newContent( - portal_type="Accounting Transaction Line", - quantity=10000, - source='account_module/receivable', - ) - payment_transaction.newContent( - portal_type="Accounting Transaction Line", - quantity=-10000, - source='account_module/sales', - ) - payment_transaction.confirm() - payment_transaction.start() - # XXX More info needed - payment_transaction.checkConsistency() + invoice = self.portal.accounting_module.newContent( + portal_type='Sale Invoice Transaction', + start_date=DateTime(), + resource='currency_module/EUR', + source_section='organisation_module/vifib_internet', + source='organisation_module/vifib_internet', + destination_section=person.getRelativeUrl(), + destination=person.getRelativeUrl(), + specialise='sale_trade_condition_module/vifib_trade_condition' + ) + invoice.newContent( + portal_type='Invoice Line', + resource=self.portal.portal_preferences.getPreferredRegistrationResource(), + quantity=1, + price=10000 + ) + sequence['invoice'] = invoice def test_automated_person_high_not_paid_locking(self): """Test that a person is automatically locked by an alarm if payment has @@ -393,16 +400,7 @@ class TestVifibSlapComputerPartitionLock(TestVifibSlapWebServiceMixin): CheckPersonUnlockedState \ Tic \ Logout \ - \ - LoginERP5TypeTestCase \ - CreateHighBalanceNotPaidPayment \ - Tic \ - Logout \ - \ - TriggerLockPersonAlarm \ - Tic \ - Logout \ - \ + ' + self.lock_user_string() + '\ LoginWebUser \ CheckPersonLockedState \ Tic \ @@ -529,13 +527,8 @@ class TestVifibSlapComputerPartitionLock(TestVifibSlapWebServiceMixin): Tic \ Logout \ ' + \ - self.create_new_user_instance_sequence_string + '\ - LoginERP5TypeTestCase \ - CreateHighBalanceNotPaidPayment \ - Tic \ - \ - TriggerLockPersonAlarm \ - Tic \ + self.create_new_user_instance_sequence_string + \ + self.lock_user_string() + '\ CheckInstanceLocked \ \ DeliverPayment \ @@ -592,9 +585,14 @@ class TestVifibSlapComputerPartitionLock(TestVifibSlapWebServiceMixin): def lock_user_string(self): return '\ LoginERP5TypeTestCase \ - CreateHighBalanceNotPaidPayment \ + CreateHighBalanceInvoiceWebUser \ Tic \ - \ + PlanInvoice \ + Tic \ + ConfirmInvoice \ + StartInvoice \ + Tic \ + CheckWebUserBalanceHighAmount \ TriggerLockPersonAlarm \ Tic \ Logout \ -- 2.30.9