Commit 518e0c7a authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting:

* test: slapos_request_update_instance_tree_open_sale_order was dropped
* test: drop outdated tests
* test: update titles
* test: InstanceTree_requestUpdateOpenSaleOrder was dropped
* test: drop tests related to dropped scripts
* test: use valid trade condition to generate the simulation
parent e62c504d
......@@ -27,15 +27,14 @@
##############################################################################
import transaction
import time
from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort, TemporaryAlarmScript
import os
import tempfile
from DateTime import DateTime
from zExceptions import Unauthorized
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL = 'sale_trade_condition_module/slapos_aggregated_trade_condition_v3'
......@@ -106,65 +105,28 @@ if context.getTitle() == 'Not visited by %s':
return wrapped
return wrapper
class TestOpenSaleOrderAlarm(SlapOSTestCaseMixin):
def test_noOSO_newPerson(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
self.tic()
self.assertEqual(None, self.portal.portal_catalog.getResultValue(
portal_type='Open Sale Order',
default_destination_uid=person.getUid()
))
def test_noOSO_after_fixConsistency(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
self.tic()
person.fixConsistency()
self.tic()
self.assertEqual(None, self.portal.portal_catalog.getResultValue(
portal_type='Open Sale Order',
default_destination_uid=person.getUid()
))
@simulateByEditWorkflowMark('InstanceTree_requestUpdateOpenSaleOrder')
def test_alarm_HS_diverged(self):
subscription = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId())
self.tic()
self.portal.portal_alarms\
.slapos_request_update_instance_tree_open_sale_order\
.activeSense()
self.tic()
self.assertEqual(
'Visited by InstanceTree_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
@simulateByTitlewMark('SimulationMovement_buildSlapOS')
def test_SimulationMovement_withoutDelivery(self):
#################################################################
# slapos_trigger_build
#################################################################
def test_SimulationMovement_buildSlapOS_alarm_withoutDelivery(self):
applied_rule = self.portal.portal_simulation.newContent(
portal_type='Applied Rule')
simulation_movement = applied_rule.newContent(
portal_type='Simulation Movement',
ledger='automated',
title='Not visited by SimulationMovement_buildSlapOS')
self.tic()
self.portal.portal_alarms.slapos_trigger_build.activeSense()
self.tic()
self.assertEqual(
'Visited by SimulationMovement_buildSlapOS',
simulation_movement.getTitle())
with TemporaryAlarmScript(self.portal, 'SimulationMovement_buildSlapOS', "''", attribute='title'):
self.tic()
self._test_alarm(
self.portal.portal_alarms.slapos_trigger_build,
simulation_movement,
'SimulationMovement_buildSlapOS',
attribute='title'
)
@simulateByTitlewMark('SimulationMovement_buildSlapOS')
def test_SimulationMovement_withDelivery(self):
def test_SimulationMovement_buildSlapOS_alarm_withDelivery(self):
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
delivery_line = delivery.newContent(portal_type='Sale Packing List Line')
......@@ -174,18 +136,21 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
portal_type='Simulation Movement',
ledger='automated',
delivery=delivery_line.getRelativeUrl(),
title='Shall be visited by SimulationMovement_buildSlapOS')
self.tic()
self.portal.portal_alarms.slapos_trigger_build.activeSense()
self.tic()
self.assertNotEqual(
'Not visited by SimulationMovement_buildSlapOS',
simulation_movement.getTitle())
title='Not visited by SimulationMovement_buildSlapOS')
with TemporaryAlarmScript(self.portal, 'SimulationMovement_buildSlapOS', "''", attribute='title'):
self.tic()
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_trigger_build,
simulation_movement,
'SimulationMovement_buildSlapOS',
attribute='title'
)
#################################################################
# SimulationMovement_buildSlapOS
#################################################################
@withAbort
def test_SimulationMovement_buildSlapOS(self):
def test_SimulationMovement_buildSlapOS_script_withoutDelivery(self):
build_simulator = tempfile.mkstemp()[1]
activate_simulator = tempfile.mkstemp()[1]
......@@ -278,7 +243,7 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
os.unlink(activate_simulator)
@withAbort
def test_SimulationMovement_buildSlapOS_withDelivery(self):
def test_SimulationMovement_buildSlapOS_script_withDelivery(self):
build_simulator = tempfile.mkstemp()[1]
activate_simulator = tempfile.mkstemp()[1]
......@@ -344,33 +309,39 @@ class TestSlapOSTriggerBuildAlarm(SlapOSTestCaseMixin):
os.unlink(activate_simulator)
class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
@simulateByTitlewMark('Delivery_manageBuildingCalculatingDelivery')
def _test(self, state, message):
#################################################################
# slapos_manage_building_calculating_delivery
#################################################################
def _test(self, state, test_function):
delivery = self.portal.sale_packing_list_module.newContent(
title='Not visited by Delivery_manageBuildingCalculatingDelivery',
ledger='automated',
portal_type='Sale Packing List')
self.portal.portal_workflow._jumpToStateFor(delivery, state)
self.tic()
self.portal.portal_alarms.slapos_manage_building_calculating_delivery\
.activeSense()
self.tic()
self.assertEqual(message, delivery.getTitle())
with TemporaryAlarmScript(self.portal, 'Delivery_manageBuildingCalculatingDelivery', "''", attribute='title'):
self.tic()
test_function(
self.portal.portal_alarms.slapos_manage_building_calculating_delivery,
delivery,
'Delivery_manageBuildingCalculatingDelivery',
attribute='title'
)
def test_building(self):
self._test('building', 'Visited by Delivery_manageBuildingCalculatingDelivery')
def test_Delivery_manageBuildingCalculatingDelivery_alarm_building(self):
self._test('building', self._test_alarm)
def test_calculating(self):
self._test('calculating', 'Visited by Delivery_manageBuildingCalculatingDelivery')
def test_Delivery_manageBuildingCalculatingDelivery_alarm_calculating(self):
self._test('calculating', self._test_alarm)
def test_diverged(self):
self._test('diverged', 'Not visited by Delivery_manageBuildingCalculatingDelivery')
def test_Delivery_manageBuildingCalculatingDelivery_alarm_diverged(self):
self._test('diverged', self._test_alarm_not_visited)
def test_solved(self):
self._test('solved', 'Not visited by Delivery_manageBuildingCalculatingDelivery')
def test_Delivery_manageBuildingCalculatingDelivery_alarm_solved(self):
self._test('solved', self._test_alarm_not_visited)
#################################################################
# Delivery_manageBuildingCalculatingDelivery
#################################################################
@withAbort
def _test_Delivery_manageBuildingCalculatingDelivery(self, state, empty=False):
updateCausalityState_simulator = tempfile.mkstemp()[1]
......@@ -421,19 +392,28 @@ class TestSlapOSManageBuildingCalculatingDeliveryAlarm(SlapOSTestCaseMixin):
if os.path.exists(updateSimulation_simulator):
os.unlink(updateSimulation_simulator)
def test_Delivery_manageBuildingCalculatingDelivery_calculating(self):
def test_Delivery_manageBuildingCalculatingDelivery_script_calculating(self):
self._test_Delivery_manageBuildingCalculatingDelivery('calculating')
def test_Delivery_manageBuildingCalculatingDelivery_building(self):
def test_Delivery_manageBuildingCalculatingDelivery_script_building(self):
self._test_Delivery_manageBuildingCalculatingDelivery('building')
def test_Delivery_manageBuildingCalculatingDelivery_solved(self):
def test_Delivery_manageBuildingCalculatingDelivery_script_solved(self):
self._test_Delivery_manageBuildingCalculatingDelivery('solved', True)
def test_Delivery_manageBuildingCalculatingDelivery_diverged(self):
def test_Delivery_manageBuildingCalculatingDelivery_script_diverged(self):
self._test_Delivery_manageBuildingCalculatingDelivery('diverged', True)
class TestSlapOSConfirmedDeliveryMixin:
class TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm(SlapOSTestCaseMixin):
destination_state = 'stopped'
script = 'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction'
portal_type = 'Sale Invoice Transaction'
alarm = 'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
#################################################################
# slapos_stop_confirmed_aggregated_sale_invoice_transaction
#################################################################
def _test(self, simulation_state, causality_state, ledger, positive,
delivery_date=DateTime('2012/04/22'),
accounting_date=DateTime('2012/04/28')):
......@@ -463,21 +443,24 @@ class TestSlapOSConfirmedDeliveryMixin:
_real(self, simulation_state, causality_state, ledger, positive,
delivery_date, accounting_date)
def test_typical(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_typical(self):
self._test('confirmed', 'solved',
'automated', True)
def test_bad_ledger(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_bad_ledger(self):
self._test('confirmed', 'solved', None, False)
def test_bad_simulation_state(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_bad_simulation_state(self):
self._test('started', 'solved',
'automated', False)
def test_bad_causality_state(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_alarm_bad_causality_state(self):
self._test('confirmed', 'calculating',
'automated', False)
#################################################################
# Delivery_stopConfirmedAggregatedSaleInvoiceTransaction
#################################################################
@withAbort
def _test_script(self, simulation_state, causality_state, ledger,
destination_state, consistency_failure=False):
......@@ -503,150 +486,34 @@ class TestSlapOSConfirmedDeliveryMixin:
delattr(Folder, 'original_checkConsistency')
self.assertEqual(destination_state, delivery.getSimulationState())
def test_script_typical(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_script_typical(self):
self._test_script('confirmed', 'solved',
'automated',
self.destination_state)
def test_script_bad_ledger(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_script_bad_ledger(self):
self._test_script('confirmed', 'solved', None, 'confirmed')
def test_script_bad_simulation_state(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_script_bad_simulation_state(self):
self._test_script('started', 'solved',
'automated',
'started')
def test_script_bad_causality_state(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_script_bad_causality_state(self):
self._test_script('confirmed', 'building',
'automated',
'confirmed')
def test_script_bad_consistency(self):
def test_Delivery_stopConfirmedAggregatedSaleInvoiceTransaction_script_bad_consistency(self):
self._test_script('confirmed', 'solved',
'automated',
'confirmed', True)
class TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm(
SlapOSTestCaseMixin, TestSlapOSConfirmedDeliveryMixin):
destination_state = 'stopped'
script = 'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction'
portal_type = 'Sale Invoice Transaction'
alarm = 'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
def createOpenOrder(self):
open_order = self.portal.open_sale_order_module.newContent(
portal_type="Open Sale Order",
ledger='automated',
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
)
open_order.order()
open_order.validate()
return open_order
def test_updatePeriod_REQUEST_disallowed(self):
self.assertRaises(
Unauthorized,
self.portal.OpenSaleOrder_updatePeriod,
REQUEST={})
def test_updatePeriod_no_person(self):
open_order = self.createOpenOrder()
open_order.OpenSaleOrder_updatePeriod()
def test_updatePeriod_validated(self):
open_order = self.createOpenOrder()
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
open_order.edit(
destination_decision_value=person,
)
open_order.newContent(
portal_type="Open Sale Order Line"
)
self.assertRaises(AssertionError, open_order.OpenSaleOrder_updatePeriod)
def test_updatePeriod_invalidated(self):
open_order = self.createOpenOrder()
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
open_order.edit(
destination_decision_value=person,
)
open_order.invalidate()
open_order.newContent(
portal_type="Open Sale Order Line"
)
open_order.OpenSaleOrder_updatePeriod()
def test_alarm(self):
open_order = self.createOpenOrder()
open_order.newContent(portal_type="Open Sale Order Line")
self.tic()
script_name = "OpenSaleOrder_updatePeriod"
alarm = self.portal.portal_alarms.slapos_update_open_sale_order_period
self._test_alarm(
alarm, open_order, script_name)
def test_alarm_invalidated(self):
open_order = self.createOpenOrder()
open_order.newContent(portal_type="Open Sale Order Line")
open_order.invalidate()
self.tic()
script_name = "OpenSaleOrder_updatePeriod"
alarm = self.portal.portal_alarms.slapos_update_open_sale_order_period
self._test_alarm_not_visited(
alarm, open_order, script_name)
def test_alarm_no_line(self):
open_order = self.createOpenOrder()
self.tic()
script_name = "OpenSaleOrder_updatePeriod"
alarm = self.portal.portal_alarms.slapos_update_open_sale_order_period
self._test_alarm_not_visited(
alarm, open_order, script_name)
class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
def createOpenOrder(self):
return self.portal.open_sale_order_module.newContent(
portal_type="Open Sale Order",
ledger='automated',
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
)
def test_alarm(self):
open_order = self.createOpenOrder()
self.tic()
# Jut wait a bit so the line has a different timestamp > 1 sec.
time.sleep(1)
open_order.newContent(portal_type="Open Sale Order Line")
self.tic()
script_name = "OpenSaleOrder_reindexIfIndexedBeforeLine"
alarm = self.portal.portal_alarms.slapos_reindex_open_sale_order
self._test_alarm(
alarm, open_order, script_name)
def test_alarm_no_line(self):
open_order = self.createOpenOrder()
self.tic()
script_name = "OpenSaleOrder_reindexIfIndexedBeforeLine"
alarm = self.portal.portal_alarms.slapos_reindex_open_sale_order
self._test_alarm_not_visited(
alarm, open_order, script_name)
class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
#################################################################
# slapos_accounting_generate_packing_list_from_tioxml
#################################################################
def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent(
title=self.generateNewId(),
......@@ -654,7 +521,7 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
)
return document
def test_alarm(self):
def test_ComputerConsumptionTioXMLFile_solveInvoicingGeneration_alarm(self):
document = self.createTioXMLFile()
document.submit()
self.tic()
......@@ -665,7 +532,7 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
self._test_alarm(
alarm, document, script_name)
def test_alarm_not_submitted(self):
def test_ComputerConsumptionTioXMLFile_solveInvoicingGeneration_alarm_not_submitted(self):
document = self.createTioXMLFile()
self.tic()
......@@ -677,7 +544,9 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCaseMixin):
#################################################################
# slapos_cancel_sale_invoice_transaction_paied_payment_list
#################################################################
def _test_payment_is_draft(self, payment_mode):
new_id = self.generateNewId()
payment_transaction = self.portal.accounting_module.newContent(
......@@ -688,19 +557,16 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
)
self.tic()
self.portal.portal_alarms.slapos_cancel_sale_invoice_transaction_paied_payment_list.activeSense()
self.tic()
self.assertNotEqual(
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered',
payment_transaction.getTitle())
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_cancel_sale_invoice_transaction_paied_payment_list,
payment_transaction,
"PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered"
)
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered')
def test_payment_is_draft_payzen(self):
def test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isDraftPayzen(self):
self._test_payment_is_draft(payment_mode="payzen")
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered')
def test_payment_is_draft_wechat(self):
def test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isDraftWeChat(self):
self._test_payment_is_draft(payment_mode="wechat")
def _test_payment_is_stopped(self, payment_mode):
......@@ -717,22 +583,18 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
payment_transaction.stop()
self.tic()
self.portal.portal_alarms.slapos_cancel_sale_invoice_transaction_paied_payment_list.activeSense()
self.tic()
self.assertNotEqual(
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered',
payment_transaction.getTitle())
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_cancel_sale_invoice_transaction_paied_payment_list,
payment_transaction,
"PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered"
)
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_stopped_payzen(self):
def test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStoppedPayzen(self):
self._test_payment_is_stopped(payment_mode="payzen")
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_stopped_wechat(self):
def test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStoppedWechat(self):
self._test_payment_is_stopped(payment_mode="wechat")
def _test_payment_is_started(self, payment_mode):
new_id = self.generateNewId()
payment_transaction = self.portal.accounting_module.newContent(
......@@ -746,17 +608,14 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
payment_transaction.start()
self.tic()
self.portal.portal_alarms.slapos_cancel_sale_invoice_transaction_paied_payment_list.activeSense()
self.tic()
self.assertNotEqual(
'Visited by PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered',
payment_transaction.getTitle())
self._test_alarm(
self.portal.portal_alarms.slapos_cancel_sale_invoice_transaction_paied_payment_list,
payment_transaction,
"PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered"
)
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_started_payzen(self):
def test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStartedPayzen(self):
self._test_payment_is_started(payment_mode="payzen")
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_started_wechat(self):
self._test_payment_is_started(payment_mode="wechat")
\ No newline at end of file
def test_PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered_alarm_isStartedWechat(self):
self._test_payment_is_started(payment_mode="wechat")
......@@ -30,7 +30,6 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbo
from zExceptions import Unauthorized
from DateTime import DateTime
import time
class TestSlapOSAccounting(SlapOSTestCaseMixin):
......@@ -90,138 +89,9 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
)
return invoice
@withAbort
def test_HS_calculateSubscriptionStartDate_REQUEST_disallowed(self):
item = self.createHostingSubscription()
self.assertRaises(
Unauthorized,
item.HostingSubscription_calculateSubscriptionStartDate,
REQUEST={})
@withAbort
def test_HS_calculateSubscriptionStartDate_noWorkflow(self):
item = self.createHostingSubscription()
item.workflow_history['instance_slap_interface_workflow'] = []
date = item.HostingSubscription_calculateSubscriptionStartDate()
self.assertEqual(date, item.getCreationDate().earliestTime())
@withAbort
def test_HS_calculateSubscriptionStartDate_withRequest(self):
item = self.createHostingSubscription()
item.workflow_history['edit_workflow'] = [{
'comment':'Directly request the instance',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'time': DateTime('2012/11/15 11:11'),
'action': 'edit'
}]
date = item.HostingSubscription_calculateSubscriptionStartDate()
self.assertEqual(date, DateTime('2012/11/15'))
@withAbort
def test_HS_calculateSubscriptionStartDate_withRequestEndOfMonth(self):
item = self.createHostingSubscription()
item.workflow_history['edit_workflow'] = [{
'comment':'Directly request the instance',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'time': DateTime('2012/11/30 11:11'),
'action': 'edit'
}]
date = item.HostingSubscription_calculateSubscriptionStartDate()
self.assertEqual(date, DateTime('2012/11/30'))
@withAbort
def test_HS_calculateSubscriptionStopDate_REQUEST_disallowed(self):
item = self.createInstanceTree()
self.assertRaises(
Unauthorized,
item.InstanceTree_calculateSubscriptionStopDate,
REQUEST={})
@withAbort
def test_IT_calculateSubscriptionStopDate_withDestroy(self):
item = self.createInstanceTree()
destroy_date = DateTime('2012/10/30')
item.workflow_history['instance_slap_interface_workflow'].append({
'comment':'Directly destroy',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'slap_state': 'destroy_requested',
'time': destroy_date,
'action': 'request_destroy'
})
date = item.InstanceTree_calculateSubscriptionStopDate()
self.assertEqual(date, DateTime('2012/10/31'))
@withAbort
def test_IT_calculateSubscriptionStopDate_noDestroy(self):
item = self.createInstanceTree()
item.workflow_history['instance_slap_interface_workflow'] = []
date = item.InstanceTree_calculateSubscriptionStopDate()
self.assertEqual(date, None)
def test_OpenSaleOrder_reindexIfIndexedBeforeLine_no_line(self):
portal = self.portal
order = self.createOpenSaleOrder()
self.tic()
indexation_timestamp = portal.portal_catalog(
uid=order.getUid(),
select_dict={'indexation_timestamp': None})[0].indexation_timestamp
order.OpenSaleOrder_reindexIfIndexedBeforeLine()
self.tic()
new_indexation_timestamp = portal.portal_catalog(
uid=order.getUid(),
select_dict={'indexation_timestamp': None})[0].indexation_timestamp
self.assertEqual(new_indexation_timestamp,
indexation_timestamp)
def test_OpenSaleOrder_reindexIfIndexedBeforeLine_line_indexed_after(self):
portal = self.portal
order = self.createOpenSaleOrder()
line = order.newContent(portal_type="Open Sale Order Line")
self.tic()
line.activate().immediateReindexObject()
# XXX One more kitten killed
time.sleep(1)
self.tic()
indexation_timestamp = portal.portal_catalog(
uid=order.getUid(),
select_dict={'indexation_timestamp': None})[0].indexation_timestamp
order.OpenSaleOrder_reindexIfIndexedBeforeLine()
self.tic()
new_indexation_timestamp = portal.portal_catalog(
uid=order.getUid(),
select_dict={'indexation_timestamp': None})[0].indexation_timestamp
self.assertNotEqual(new_indexation_timestamp,
indexation_timestamp)
def test_OpenSaleOrder_reindexIfIndexedBeforeLine_line_indexed_before(self):
portal = self.portal
order = self.createOpenSaleOrder()
order.newContent(portal_type="Open Sale Order Line")
self.tic()
order.activate().immediateReindexObject()
# XXX One more kitten killed
time.sleep(1)
self.tic()
indexation_timestamp = portal.portal_catalog(
uid=order.getUid(),
select_dict={'indexation_timestamp': None})[0].indexation_timestamp
order.OpenSaleOrder_reindexIfIndexedBeforeLine()
self.tic()
new_indexation_timestamp = portal.portal_catalog(
uid=order.getUid(),
select_dict={'indexation_timestamp': None})[0].indexation_timestamp
self.assertEqual(new_indexation_timestamp,
indexation_timestamp)
def test_OpenSaleOrder_reindexIfIndexedBeforeLine_REQUEST_disallowed(self):
self.assertRaises(
Unauthorized,
self.portal.OpenSaleOrder_reindexIfIndexedBeforeLine,
REQUEST={})
#################################################################
# SaleInvoiceTransaction_createReversalSaleInvoiceTransaction
#################################################################
def test_SaleInvoiceTransaction_createReversalSaleInvoiceTransaction_redirect_payzen(self):
sale_invoice_transaction = self.createSaleInvoiceTransactionForReversal(payment_mode='payzen')
self.tic()
......@@ -254,6 +124,9 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
"%s doesn't end with %s?portal_status_message=The%%20payment%%20mode%%20is%%20unsupported." % (
redirect, sale_invoice_transaction.getRelativeUrl()))
#################################################################
# SaleInvoiceTransaction_resetPaymentMode
#################################################################
def test_SaleInvoiceTransaction_resetPaymentMode(self):
sale_invoice_transaction = self.portal.accounting_module.newContent(portal_type="Sale Invoice Transaction")
sale_invoice_transaction.edit(payment_mode="unknown",
......@@ -279,15 +152,26 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode,
REQUEST={})
#################################################################
# AccountingTransactionModule_getUnpaidInvoiceList
#################################################################
def test_AccountingTransactionModule_getUnpaidInvoiceList(self):
project = self.addProject()
person = self.makePerson(project, user=1)
sale_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference=self.generateNewId(),
specialise="business_process_module/slapos_ultimate_business_process"
)
sale_trade_condition.validate()
template = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredDefaultPrePaymentSubscriptionInvoiceTemplate())
current_invoice = template.Base_createCloneDocument(batch_mode=1)
current_invoice.edit(
specialise_value=sale_trade_condition,
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
......@@ -300,7 +184,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
cell = current_invoice["1"]["movement_0"]
cell.edit(quantity=1)
cell.setPrice(1)
current_invoice.plan()
current_invoice.confirm()
current_invoice.startBuilding()
......@@ -308,8 +192,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
current_invoice.stop()
self.tic()
current_invoice.Delivery_manageBuildingCalculatingDelivery()
self.tic()
applied_rule = current_invoice.getCausalityRelated(portal_type="Applied Rule")
for sm in self.portal.portal_catalog(portal_type='Simulation Movement',
simulation_state=['draft', 'planned', None],
......@@ -376,6 +259,9 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
[i.getRelativeUrl() for i in unpaid_invoice_list],
[])
#################################################################
# SaleInvoiceTransaction_createReversalSaleInvoiceTransaction
#################################################################
@withAbort
def test_createReversalSaleInvoiceTransaction_bad_portal_type(self):
self.assertRaises(
......@@ -629,6 +515,9 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
def test_createReversalSaleInvoiceTransaction_wechat_ok_dont_autocancel(self):
self.test_createReversalSaleInvoiceTransaction_ok_dont_autocancel(payment_mode='wechat')
#################################################################
# AccountingTransaction_getPaymentState
#################################################################
@withAbort
def test_AccountingTransaction_getPaymentState_draft_payment(self):
invoice = self.createSaleInvoiceTransaction()
......@@ -799,12 +688,18 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.assertEqual("Paid",
invoice.AccountingTransaction_getPaymentState())
#################################################################
# Base_getReceivableAccountList
#################################################################
def test_Base_getReceivableAccountList(self):
account_list = self.portal.Base_getReceivableAccountList()
self.assertIn('account_module/receivable',
[i.getRelativeUrl() for i in account_list])
#################################################################
# PaymentTransaction_start
#################################################################
def test_PaymentTransaction_start(self):
sale_invoice_transaction = self.portal.accounting_module.newContent(
......@@ -832,560 +727,3 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.assertEqual("started",
payment_transaction.getSimulationState())
class TestInstanceTree_requestUpdateOpenSaleOrder(SlapOSTestCaseMixin):
def test_REQUEST_disallowed(self):
subscription = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
self.assertRaises(
Unauthorized,
subscription.InstanceTree_requestUpdateOpenSaleOrder,
REQUEST={})
def test_solved_InstanceTree(self):
subscription = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
self.portal.portal_workflow._jumpToStateFor(subscription, 'solved')
open_sale_order = subscription.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(subscription.getCausalityState(), 'solved')
self.assertEqual(open_sale_order, None)
def test_empty_InstanceTree_ok(self):
software_product, release_variation, type_variation, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=42)
project = instance_tree.getFollowUpValue()
person = instance_tree.getDestinationSectionValue()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree.getCausalityState(), 'solved')
self.assertNotEqual(open_sale_order, None)
self.assertEqual('validated', open_sale_order.getValidationState())
self.tic()
# Check Open Sale Order
self.assertEqual(
open_sale_order.getLedger(),
"automated"
)
self.assertEqual(
open_sale_order.getPriceCurrency(),
project.Project_getAccountingCurrency()
)
sale_trade_condition = project.getSpecialiseValue()
self.assertEqual(
open_sale_order.getSpecialise(),
sale_trade_condition.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getSource(),
sale_trade_condition.getSource()
)
self.assertEqual(
open_sale_order.getSourceSection(),
sale_trade_condition.getSourceSection()
)
self.assertEqual(
open_sale_order.getDestinationProject(),
project.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getDestination(),
person.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getDestinationSection(),
person.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getDestinationDecision(),
person.getRelativeUrl()
)
# Check Open Sale Order Line
open_sale_order_line_list = open_sale_order.contentValues(
portal_type='Open Sale Order Line')
self.assertEqual(1, len(open_sale_order_line_list))
line = open_sale_order_line_list[0].getObject()
self.assertEqual(
line.getResource(),
software_product.getRelativeUrl()
)
self.assertEqual(
line.getSoftwareRelease(),
release_variation.getRelativeUrl()
)
self.assertEqual(
line.getSoftwareType(),
type_variation.getRelativeUrl()
)
self.assertEqual(line.getTotalQuantity(), 1)
self.assertEqual(
software_product.getQuantityUnit(),
line.getQuantityUnit()
)
self.assertEqual(
software_product.getUse(),
line.getUse()
)
self.assertSameSet(
software_product.getBaseContributionList(),
line.getBaseContributionList()
)
self.assertEqual(
line.getTotalPrice(),
42
)
self.assertEqual(
line.getPriceCurrency(),
project.Project_getAccountingCurrency()
)
# Check Open Sale Order Cell
open_sale_order_cell_list = line.contentValues(
portal_type='Open Sale Order Cell')
self.assertEqual(1, len(open_sale_order_cell_list))
cell = open_sale_order_cell_list[0].getObject()
self.assertEqual(cell.getQuantity(), 1)
self.assertEqual(cell.getPrice(), 42)
hosting_subscription = cell.getAggregateValue(portal_type="Hosting Subscription")
self.assertSameSet(
cell.getAggregateList(),
[hosting_subscription.getRelativeUrl(), instance_tree.getRelativeUrl()]
)
self.assertEqual("validated",
hosting_subscription.getValidationState())
"""
self.assertEqual(DateTime().earliestTime(), line.getStartDate())
self.assertEqual(min(DateTime().day(), 28),
hosting_subscription.getPeriodicityMonthDay())
start_date = addToDate(line.getStartDate(), to_add={'month': 1})
start_date = addToDate(start_date, to_add={'second': -1})
while start_date.day() >= 28:
start_date = addToDate(start_date, to_add={'day': -1})
self.assertEqual(start_date, line.getStopDate())
# XXX XXX Open Order start_date, stop_date, effective_date
"""
def test_empty_InstanceTree_withDedicatedTradeConditionAndSupply(self):
software_product, release_variation, type_variation, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=42, has_organisation=True)
project = instance_tree.getFollowUpValue()
person = instance_tree.getDestinationSectionValue()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
sale_trade_condition = project.getSpecialiseValue()
# Create dedicated trade condition and supply
dedicated_sale_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='customer_%s' % person.getTitle(),
# XXX hardcoded
specialise_value=sale_trade_condition,
destination_project_value=project,
destination_section_value=person
)
dedicated_sale_trade_condition.validate()
dedicated_sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
destination_project_value=project,
destination_section_value=person,
price_currency=project.Project_getAccountingCurrency()
)
dedicated_sale_supply.newContent(
portal_type="Sale Supply Line",
base_price=43,
resource_value=software_product
)
dedicated_sale_supply.validate()
self.tic()
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree.getCausalityState(), 'solved')
self.assertNotEqual(open_sale_order, None)
self.assertEqual('validated', open_sale_order.getValidationState())
self.tic()
# Check Open Sale Order
self.assertEqual(
open_sale_order.getLedger(),
"automated"
)
self.assertEqual(
open_sale_order.getPriceCurrency(),
project.Project_getAccountingCurrency()
)
self.assertEqual(
open_sale_order.getSpecialise(),
dedicated_sale_trade_condition.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getSource(),
sale_trade_condition.getSource()
)
self.assertEqual(
open_sale_order.getSourceSection(),
sale_trade_condition.getSourceSection()
)
self.assertEqual(
open_sale_order.getDestinationProject(),
project.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getDestination(),
person.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getDestinationSection(),
person.getRelativeUrl()
)
self.assertEqual(
open_sale_order.getDestinationDecision(),
person.getRelativeUrl()
)
# Check Open Sale Order Line
open_sale_order_line_list = open_sale_order.contentValues(
portal_type='Open Sale Order Line')
self.assertEqual(1, len(open_sale_order_line_list))
line = open_sale_order_line_list[0].getObject()
self.assertEqual(
line.getResource(),
software_product.getRelativeUrl()
)
self.assertEqual(
line.getSoftwareRelease(),
release_variation.getRelativeUrl()
)
self.assertEqual(
line.getSoftwareType(),
type_variation.getRelativeUrl()
)
self.assertEqual(line.getTotalQuantity(), 1)
self.assertEqual(
software_product.getQuantityUnit(),
line.getQuantityUnit()
)
self.assertEqual(
software_product.getUse(),
line.getUse()
)
self.assertSameSet(
software_product.getBaseContributionList(),
line.getBaseContributionList()
)
self.assertEqual(
line.getTotalPrice(),
43
)
self.assertEqual(
line.getPriceCurrency(),
project.Project_getAccountingCurrency()
)
# Check Open Sale Order Cell
open_sale_order_cell_list = line.contentValues(
portal_type='Open Sale Order Cell')
self.assertEqual(1, len(open_sale_order_cell_list))
cell = open_sale_order_cell_list[0].getObject()
self.assertEqual(cell.getQuantity(), 1)
self.assertEqual(cell.getPrice(), 43)
hosting_subscription = cell.getAggregateValue(portal_type="Hosting Subscription")
self.assertSameSet(
cell.getAggregateList(),
[hosting_subscription.getRelativeUrl(), instance_tree.getRelativeUrl()]
)
self.assertEqual("validated",
hosting_subscription.getValidationState())
"""
self.assertEqual(DateTime().earliestTime(), line.getStartDate())
self.assertEqual(min(DateTime().day(), 28),
hosting_subscription.getPeriodicityMonthDay())
start_date = addToDate(line.getStartDate(), to_add={'month': 1})
start_date = addToDate(start_date, to_add={'second': -1})
while start_date.day() >= 28:
start_date = addToDate(start_date, to_add={'day': -1})
self.assertEqual(start_date, line.getStopDate())
# XXX XXX Open Order start_date, stop_date, effective_date
"""
def test_empty_InstanceTree_noPerson(self):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=42)
instance_tree.setDestinationSection(None)
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
self.assertEqual(open_sale_order, None)
self.assertEqual(
self.portal.portal_workflow.getInfoFor(
ob=instance_tree, name='comment', wf_id='edit_workflow'
),
None
)
def test_empty_InstanceTree_noProduct(self):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=42)
instance_tree.setUrlString(instance_tree.getUrlString() + 'foo')
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
self.assertEqual(open_sale_order, None)
self.assertEqual(
self.portal.portal_workflow.getInfoFor(
ob=instance_tree, name='comment', wf_id='edit_workflow'
),
"No software product found"
)
def test_empty_InstanceTree_noCurrency(self):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
self.assertEqual(open_sale_order, None)
self.assertEqual(
self.portal.portal_workflow.getInfoFor(
ob=instance_tree, name='comment', wf_id='edit_workflow'
),
"No currency found"
)
def test_empty_InstanceTree_noPrice(self):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True)
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
self.assertEqual(open_sale_order, None)
self.assertEqual(
self.portal.portal_workflow.getInfoFor(
ob=instance_tree, name='comment', wf_id='edit_workflow'
),
"No price found"
)
def test_usualLifetime_InstanceTree(self):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=9)
self.portal.portal_workflow._jumpToStateFor(instance_tree, 'validated')
person = instance_tree.getDestinationSectionValue()
request_time = DateTime('2012/01/01')
instance_tree.workflow_history['instance_slap_interface_workflow'] = [{
'comment':'Simulated request instance',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'slap_state': 'start_requested',
'time': request_time,
'action': 'request_instance'
}]
self.tic()
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(instance_tree.getCausalityState(), 'solved')
self.assertEqual('validated', open_sale_order.getValidationState())
destroy_time = DateTime('2112/02/01')
instance_tree.workflow_history['instance_slap_interface_workflow'].append({
'comment':'Simulated request instance',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'slap_state': 'destroy_requested',
'time': destroy_time,
'action': 'request_destroy'
})
instance_tree.diverge()
self.tic()
second_open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(second_open_sale_order, None)
self.tic()
self.assertEqual(instance_tree.getCausalityState(), 'solved')
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
default_destination_uid=person.getUid()
)
self.assertEqual(1, len(open_sale_order_list))
self.assertEqual('archived', open_sale_order.getValidationState())
# self.assertEqual(DateTime().earliestTime(), archived_line.getStartDate())
# self.assertEqual(DateTime('2112/02/02'), line.getStopDate())
def test_lateAnalysed_InstanceTree(self):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=9)
person = instance_tree.getDestinationSectionValue()
self.portal.portal_workflow._jumpToStateFor(instance_tree, 'validated')
instance_tree.workflow_history['instance_slap_interface_workflow'] = []
request_time = DateTime('2012/01/01')
instance_tree.workflow_history['instance_slap_interface_workflow'].append({
'comment':'Simulated request instance',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'slap_state': 'start_requested',
'time': request_time,
'action': 'request_instance'
})
destroy_time = DateTime('2012/02/01')
instance_tree.workflow_history['instance_slap_interface_workflow'].append({
'comment':'Simulated request instance',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'slap_state': 'destroy_requested',
'time': destroy_time,
'action': 'request_destroy'
})
instance_tree.edit(periodicity_month_day_list=[])
instance_tree.fixConsistency()
self.tic()
open_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(open_order, None)
self.tic()
self.assertEqual(instance_tree.getCausalityState(), 'solved')
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
default_destination_uid=person.getUid()
)
self.assertEqual(0, len(open_sale_order_list))
self.assertEqual(
self.portal.portal_workflow.getInfoFor(
ob=instance_tree, name='comment', wf_id='slapos_api_invoicing_workflow'
),
"No open order needed as it was never allocated"
)
def test_two_InstanceTree(self):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=9)
person = instance_tree.getDestinationSectionValue()
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree.getCausalityState(), 'solved')
self.assertEqual('validated', open_sale_order.getValidationState())
instance_tree2 = instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree2.edit(reference='TESTHS-%s' % self.generateNewId(),
title='Test Title %s' % self.generateNewId())
self.portal.portal_workflow._jumpToStateFor(instance_tree2, 'validated')
open_sale_order2 = instance_tree2.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(instance_tree2.getCausalityState(), 'solved')
self.assertEqual('validated', open_sale_order2.getValidationState())
self.tic()
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
default_destination_uid=person.getUid()
)
self.assertEqual(2, len(open_sale_order_list))
def test_instance_tree_start_date_not_changed(self):
# if there was no request_instance the getCreationDate has been used
# but if request_instance appeared start_date is not changed
_, _, _, _, _, subscription = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=9)
person = subscription.getDestinationSectionValue()
subscription.InstanceTree_requestUpdateOpenSaleOrder()
self.tic()
request_time = DateTime('2112/01/01')
subscription.workflow_history['instance_slap_interface_workflow'].append({
'comment':'Simulated request instance',
'error_message': '',
'actor': 'ERP5TypeTestCase',
'slap_state': 'start_requested',
'time': request_time,
'action': 'request_instance'
})
self.tic()
subscription.InstanceTree_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(subscription.getCausalityState(), 'solved')
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
default_destination_uid=person.getUid()
)
self.assertEqual(1, len(open_sale_order_list))
open_sale_order = open_sale_order_list[0].getObject()
self.assertEqual('validated', open_sale_order.getValidationState())
open_sale_order_line_list = open_sale_order.contentValues(
portal_type='Open Sale Order Line')
self.assertEqual(1, len(open_sale_order_line_list))
line = open_sale_order_line_list[0].getObject()
self.assertEqual(subscription.getCreationDate().earliestTime(),
line.getStartDate())
def test_instance_tree_diverged_to_solve(self):
# check that HS becomes solved even if not modification is needed on open
# order
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True, base_price=9)
self.portal.portal_workflow._jumpToStateFor(instance_tree, 'validated')
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
self.tic()
open_sale_order = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(instance_tree.getCausalityState(), 'solved')
self.portal.portal_workflow._jumpToStateFor(instance_tree, 'diverged')
instance_tree.reindexObject()
self.assertEqual(instance_tree.getCausalityState(), 'diverged')
self.assertEqual(instance_tree.getSlapState(), 'start_requested')
self.tic()
open_sale_order2 = instance_tree.InstanceTree_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(open_sale_order2, None)
self.assertEqual(open_sale_order.getValidationState(), 'validated')
self.assertEqual(instance_tree.getCausalityState(), 'solved')
self.assertEqual(
self.portal.portal_workflow.getInfoFor(
ob=instance_tree, name='comment', wf_id='slapos_api_invoicing_workflow'
),
"Nothing to do on open order."
)
def test_empty_destroyed_InstanceTree(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
self.tic()
subscription = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId(),
destination_section=person.getRelativeUrl())
self.portal.portal_workflow._jumpToStateFor(subscription, 'validated')
self.portal.portal_workflow._jumpToStateFor(subscription, 'destroy_requested')
self.tic()
open_sale_order = subscription.InstanceTree_requestUpdateOpenSaleOrder()
self.assertEqual(open_sale_order, None)
self.tic()
self.assertEqual(subscription.getCausalityState(), 'solved')
self.assertEqual(
self.portal.portal_workflow.getInfoFor(
ob=subscription, name='comment', wf_id='slapos_api_invoicing_workflow'
),
"No open order needed as it was never allocated"
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment