Commit a2f9d3e9 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Test open Regularisation Request scenario

   Whenever you post a ticket on a suspended Regularisation Request it interrupts the triggers and nothing is removed, until it is suspended again.
parent 92e4d75a
...@@ -12,12 +12,23 @@ from DateTime import DateTime ...@@ -12,12 +12,23 @@ from DateTime import DateTime
class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
def test_notPaidInvoiceScenario(self): def afterSetUp(self):
""" TestSlapOSVirtualMasterScenarioMixin.afterSetUp(self)
Ensure services are destroyed, open order are archived, and
deposit is used to pay the invoice # Ensure that the required alarms are enabled, else things dont work.
""" for required_alarm_id in ['slapos_crm_create_regularisation_request',
creation_date = DateTime('2020/05/19') 'slapos_crm_invalidate_suspended_regularisation_request',
'slapos_crm_trigger_stop_reminder_escalation',
'slapos_crm_trigger_stop_acknowledgment_escalation',
'slapos_crm_trigger_delete_reminder_escalation',
'slapos_crm_trigger_acknowledgment_escalation',
'slapos_crm_stop_instance_tree',
'slapos_crm_delete_instance_tree']:
self.assertTrue(
self.portal.portal_alarms[required_alarm_id].isEnabled(),
"%s alarm is not enabled" % required_alarm_id)
def bootstrapCRMScenario(self, creation_date):
with PinnedDateTime(self, creation_date): with PinnedDateTime(self, creation_date):
owner_person, currency, project = self.bootstrapAccountingTest() owner_person, currency, project = self.bootstrapAccountingTest()
# Create software product # Create software product
...@@ -119,6 +130,17 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -119,6 +130,17 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
follow_up__uid=project.getUid() follow_up__uid=project.getUid()
) )
return project, owner_person, instance_tree, compute_node
def test_notPaidInvoiceScenario(self):
"""
Ensure services are destroyed, open order are archived, and
deposit is used to pay the invoice
"""
creation_date = DateTime('2020/05/19')
project, owner_person, instance_tree, compute_node = self.bootstrapCRMScenario(
creation_date)
################################################## ##################################################
# Ensure new monthly invoices are created # Ensure new monthly invoices are created
# Regularisation Request must also be created # Regularisation Request must also be created
...@@ -131,6 +153,7 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -131,6 +153,7 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
portal_type='Regularisation Request', portal_type='Regularisation Request',
destination__uid=owner_person.getUid() destination__uid=owner_person.getUid()
) )
self.assertNotEqual(regularisation_request, None)
self.assertEqual(regularisation_request.getSimulationState(), 'suspended') self.assertEqual(regularisation_request.getSimulationState(), 'suspended')
################################################## ##################################################
...@@ -206,3 +229,77 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -206,3 +229,77 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
with PinnedDateTime(self, creation_date + 5): with PinnedDateTime(self, creation_date + 5):
self.checkERP5StateBeforeExit() self.checkERP5StateBeforeExit()
def test_notPaidInvoiceScenario_open_regularisation_request(self):
"""
Ensure services are destroyed, open order are archived, and
deposit is used to pay the invoice
"""
creation_date = DateTime('2020/05/19')
project, owner_person, instance_tree, compute_node = self.bootstrapCRMScenario(
creation_date)
##################################################
# Ensure new monthly invoices are created
# Regularisation Request must also be created
with PinnedDateTime(self, creation_date + 32):
self.logout()
self.login()
self.portal.portal_alarms.update_open_order_simulation.activeSense()
self.tic()
regularisation_request = self.portal.portal_catalog.getResultValue(
portal_type='Regularisation Request',
destination__uid=owner_person.getUid()
)
self.assertNotEqual(regularisation_request, None)
self.assertEqual(regularisation_request.getSimulationState(), 'suspended')
with PinnedDateTime(self, creation_date + 32.1):
self.login(owner_person.getUserId())
event = regularisation_request.Ticket_createProjectEvent(
'foo', 'incoming', 'Web Message',
regularisation_request.getResource(),
'bar', "text/plain"
)
self.tic()
self.assertEqual(regularisation_request.getSimulationState(), 'validated')
self.assertEqual(event.getSimulationState(), 'delivered')
##################################################
# Trigger regularisation request escalation
self.logout()
self.login()
for date_offset in range(33, 70, 1):
# Trigger the alarm everyday, to not depend too much
# of the alarm crm delay current implementation
with PinnedDateTime(self, creation_date + date_offset):
for alarm_id in [
'slapos_crm_trigger_acknowledgment_escalation',
'slapos_crm_trigger_delete_reminder_escalation',
'update_open_order_simulation',
'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
]:
self.portal.portal_alarms[alarm_id].activeSense()
self.tic()
##################################################
# All items are preserved nothing happened
self.assertEqual(project.getValidationState(), 'validated')
self.assertEqual(instance_tree.getValidationState(), 'validated')
self.assertEqual(instance_tree.getSlapState(), 'start_requested')
self.assertEqual(compute_node.getValidationState(), 'validated')
open_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
destination_section__uid=owner_person.getUid()
)
self.assertEqual(len(open_order_list), 3)
for open_order in open_order_list:
self.assertEqual(open_order.getValidationState(), 'validated')
self.assertEqual(regularisation_request.getSimulationState(), 'validated')
self.assertEqual(regularisation_request.getResourceId(),
'slapos_crm_acknowledgement')
with PinnedDateTime(self, creation_date + 5):
self.checkERP5StateBeforeExit()
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