Commit db3a5a39 authored by Romain Courteaud's avatar Romain Courteaud

Automatically close not needed support request.

parent 1a8cea16
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_updatePayzenSuspendedSupportRequest</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_payzen_update_suspended_support_request</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1288051200.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>sense_method_id</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Handles suspended Support Request</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Support Request", \n
simulation_state=["suspended"],\n
method_id=\'SupportRequest_updateStatus\',\n
default_source_project_portal_type="Payment Transaction",\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_updatePayzenSuspendedSupportRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># from DateTime import DateTime\n
portal = context.getPortalObject()\n
\n
state = context.getSimulationState()\n
payment = context.getSourceProjectValue(portal_type="Payment Transaction")\n
if (state != \'suspended\') or \\\n
(payment is None) or \\\n
(payment.getPaymentMode() != \'payzen\') or \\\n
(payment.getSimulationState() not in ("cancelled", "stopped", "delivered")):\n
return\n
else:\n
context.invalidate(comment="Payzen payment state is %s" % payment.getSimulationState())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequest_updateStatus</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -517,3 +517,233 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
self.assertNotEqual(
'Visited by PaymentTransaction_updateStatus',
transaction.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSPayzenUpdateSuspendedSupportRequest(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
def test_not_suspended_support_request(self):
new_id = self.generateNewId()
payment = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Payment %s" % new_id,
reference="TESTPAY-%s" % new_id,
payment_mode="payzen",
)
payment.cancel()
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
source_project_value=payment,
)
simulation_state = ticket.getSimulationState()
modification_date = ticket.getModificationDate()
ticket.SupportRequest_updateStatus()
self.assertEquals(ticket.getSimulationState(), simulation_state)
self.assertEquals(ticket.getModificationDate(), modification_date)
def test_not_payzen_payment_support_request(self):
new_id = self.generateNewId()
payment = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Payment %s" % new_id,
reference="TESTPAY-%s" % new_id,
)
payment.cancel()
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
source_project_value=payment,
)
ticket.validate()
ticket.suspend()
simulation_state = ticket.getSimulationState()
modification_date = ticket.getModificationDate()
ticket.SupportRequest_updateStatus()
self.assertEquals(ticket.getSimulationState(), simulation_state)
self.assertEquals(ticket.getModificationDate(), modification_date)
def test_not_finalyzed_payment_support_request(self):
new_id = self.generateNewId()
payment = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Payment %s" % new_id,
reference="TESTPAY-%s" % new_id,
payment_mode="payzen",
)
payment.start()
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
source_project_value=payment,
)
ticket.validate()
ticket.suspend()
simulation_state = ticket.getSimulationState()
modification_date = ticket.getModificationDate()
ticket.SupportRequest_updateStatus()
self.assertEquals(ticket.getSimulationState(), simulation_state)
self.assertEquals(ticket.getModificationDate(), modification_date)
def test_no_payment_support_request(self):
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
)
ticket.validate()
ticket.suspend()
simulation_state = ticket.getSimulationState()
modification_date = ticket.getModificationDate()
ticket.SupportRequest_updateStatus()
self.assertEquals(ticket.getSimulationState(), simulation_state)
self.assertEquals(ticket.getModificationDate(), modification_date)
def test_cancel_payment_support_request(self):
new_id = self.generateNewId()
payment = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Payment %s" % new_id,
reference="TESTPAY-%s" % new_id,
payment_mode="payzen",
)
payment.cancel()
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
source_project_value=payment,
)
ticket.validate()
ticket.suspend()
ticket.SupportRequest_updateStatus()
self.assertEquals(ticket.getSimulationState(), "invalidated")
def test_closed_payment_support_request(self):
new_id = self.generateNewId()
payment = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Payment %s" % new_id,
reference="TESTPAY-%s" % new_id,
payment_mode="payzen",
)
_jumpToStateFor = self.portal.portal_workflow._jumpToStateFor
_jumpToStateFor(payment, "stopped")
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
source_project_value=payment,
)
ticket.validate()
ticket.suspend()
ticket.SupportRequest_updateStatus()
self.assertEquals(ticket.getSimulationState(), "invalidated")
def _simulateSupportRequest_updateStatus(self):
script_name = 'SupportRequest_updateStatus'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by SupportRequest_updateStatus') """ )
transaction.commit()
def _dropSupportRequest_updateStatus(self):
script_name = 'SupportRequest_updateStatus'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_no_payment_support_request(self):
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
)
ticket.validate()
ticket.suspend()
self.tic()
self._simulateSupportRequest_updateStatus()
try:
self.portal.portal_alarms.\
slapos_payzen_update_suspended_support_request.activeSense()
self.tic()
finally:
self._dropSupportRequest_updateStatus()
self.assertNotEqual(
'Visited by SupportRequest_updateStatus',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_suspended_support_request(self):
new_id = self.generateNewId()
payment = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Payment %s" % new_id,
reference="TESTPAY-%s" % new_id,
)
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
source_project_value=payment,
)
ticket.validate()
self.tic()
self._simulateSupportRequest_updateStatus()
try:
self.portal.portal_alarms.\
slapos_payzen_update_suspended_support_request.activeSense()
self.tic()
finally:
self._dropSupportRequest_updateStatus()
self.assertNotEqual(
'Visited by SupportRequest_updateStatus',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_suspended_support_request(self):
new_id = self.generateNewId()
payment = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Payment %s" % new_id,
reference="TESTPAY-%s" % new_id,
)
new_id = self.generateNewId()
ticket = self.portal.support_request_module.newContent(
portal_type='Support Request',
title="Ticket %s" % new_id,
reference="TESTSUPREQ-%s" % new_id,
source_project_value=payment,
)
ticket.validate()
ticket.suspend()
self.tic()
self._simulateSupportRequest_updateStatus()
try:
self.portal.portal_alarms.\
slapos_payzen_update_suspended_support_request.activeSense()
self.tic()
finally:
self._dropSupportRequest_updateStatus()
self.assertEqual(
'Visited by SupportRequest_updateStatus',
ticket.workflow_history['edit_workflow'][-1]['comment'])
102
\ No newline at end of file
103
\ No newline at end of file
portal_alarms/slapos_payzen_update_confirmed_payment
portal_alarms/slapos_payzen_update_started_payment
portal_alarms/slapos_payzen_update_suspended_support_request
portal_integrations/slapos_payzen_test_integration
portal_integrations/slapos_payzen_test_integration/Causality
portal_integrations/slapos_payzen_test_integration/Resource
......
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