Commit 0fd6a84c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Update, lint and clean up testSlapOSCRMSkins and testSlapOSCRMAlarm

   This reduces the code duplication reusing API to test alarms
parent 8bd0a861
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from erp5.component.test.SlapOSTestCaseMixin import \ from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin, simulate SlapOSTestCaseMixin, SlapOSTestCaseMixinWithAbort
from unittest import skip from unittest import skip
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSCRMCreateRegularisationRequest(SlapOSTestCaseMixin): class TestSlapOSCRMCreateRegularisationRequest(SlapOSTestCaseMixin):
def _simulatePerson_checkToCreateRegularisationRequest(self):
script_name = 'Person_checkToCreateRegularisationRequest'
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 Person_checkToCreateRegularisationRequest') """ )
transaction.commit()
def _dropPerson_checkToCreateRegularisationRequest(self):
script_name = 'Person_checkToCreateRegularisationRequest'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_expected_person(self): def test_alarm_expected_person(self):
new_id = self.generateNewId() new_id = self.generateNewId()
person = self.portal.person_module.newContent( person = self.portal.person_module.newContent(
...@@ -37,16 +17,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P ...@@ -37,16 +17,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
person.validate() person.validate()
self.tic() self.tic()
self._simulatePerson_checkToCreateRegularisationRequest() alarm = self.portal.portal_alarms.\
try: slapos_crm_create_regularisation_request
self.portal.portal_alarms.\ self._test_alarm(alarm, person, "Person_checkToCreateRegularisationRequest")
slapos_crm_create_regularisation_request.activeSense()
self.tic()
finally:
self._dropPerson_checkToCreateRegularisationRequest()
self.assertEqual(
'Visited by Person_checkToCreateRegularisationRequest',
person.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_no_email(self): def test_alarm_no_email(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -58,16 +31,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P ...@@ -58,16 +31,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
person.validate() person.validate()
self.tic() self.tic()
self._simulatePerson_checkToCreateRegularisationRequest() alarm = self.portal.portal_alarms.\
try: slapos_crm_create_regularisation_request
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, person, "Person_checkToCreateRegularisationRequest")
slapos_crm_create_regularisation_request.activeSense()
self.tic()
finally:
self._dropPerson_checkToCreateRegularisationRequest()
self.assertNotEqual(
'Visited by Person_checkToCreateRegularisationRequest',
person.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_validated(self): def test_alarm_not_validated(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -81,21 +47,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P ...@@ -81,21 +47,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
person.invalidate() person.invalidate()
self.tic() self.tic()
self._simulatePerson_checkToCreateRegularisationRequest() alarm = self.portal.portal_alarms.\
try: slapos_crm_create_regularisation_request
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, person, "Person_checkToCreateRegularisationRequest")
slapos_crm_create_regularisation_request.activeSense()
self.tic()
finally:
self._dropPerson_checkToCreateRegularisationRequest()
self.assertNotEqual(
'Visited by Person_checkToCreateRegularisationRequest',
person.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -105,61 +62,25 @@ class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(SlapOSTestCaseMixin) ...@@ -105,61 +62,25 @@ class TestSlapOSCrmInvalidateSuspendedRegularisationRequest(SlapOSTestCaseMixin)
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_invalidateIfPersonBalanceIsOk(self):
script_name = 'RegularisationRequest_invalidateIfPersonBalanceIsOk'
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 RegularisationRequest_invalidateIfPersonBalanceIsOk') """ )
transaction.commit()
def _dropRegularisationRequest_invalidateIfPersonBalanceIsOk(self):
script_name = 'RegularisationRequest_invalidateIfPersonBalanceIsOk'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_not_suspended_regularisation_request(self): def test_alarm_not_suspended_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.validate() ticket.validate()
self.tic()
self._simulateRegularisationRequest_invalidateIfPersonBalanceIsOk()
try:
self.portal.portal_alarms.\
slapos_crm_invalidate_suspended_regularisation_request.activeSense()
self.tic() self.tic()
finally: alarm = self.portal.portal_alarms.\
self._dropRegularisationRequest_invalidateIfPersonBalanceIsOk() slapos_crm_invalidate_suspended_regularisation_request
self.assertNotEqual( self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_invalidateIfPersonBalanceIsOk")
'Visited by RegularisationRequest_invalidateIfPersonBalanceIsOk',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_suspended_regularisation_request(self): def test_alarm_suspended_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.validate() ticket.validate()
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_invalidateIfPersonBalanceIsOk() alarm = self.portal.portal_alarms.\
try: slapos_crm_invalidate_suspended_regularisation_request
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket, "RegularisationRequest_invalidateIfPersonBalanceIsOk")
slapos_crm_invalidate_suspended_regularisation_request.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_invalidateIfPersonBalanceIsOk()
self.assertEqual(
'Visited by RegularisationRequest_invalidateIfPersonBalanceIsOk',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -169,39 +90,15 @@ class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(SlapOSTe ...@@ -169,39 +90,15 @@ class TestSlapOSCrmCancelInvoiceRelatedToSuspendedRegularisationRequest(SlapOSTe
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty(self):
script_name = 'RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty'
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 RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty') """ )
transaction.commit()
def _dropRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty(self):
script_name = 'RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_not_suspended_regularisation_request(self): def test_alarm_not_suspended_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.validate() ticket.validate()
self.tic() self.tic()
self._simulateRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty() alarm = self.portal.portal_alarms.\
try: slapos_crm_cancel_invoice
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket,
slapos_crm_cancel_invoice.activeSense() "RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty")
self.tic()
finally:
self._dropRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty()
self.assertNotEqual(
'Visited by RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_suspended_regularisation_request(self): def test_alarm_suspended_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -209,21 +106,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -209,21 +106,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty() alarm = self.portal.portal_alarms.\
try: slapos_crm_cancel_invoice
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket,
slapos_crm_cancel_invoice.activeSense() "RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty")
self.tic()
finally:
self._dropRegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty()
self.assertEqual(
'Visited by RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -233,24 +121,6 @@ class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(SlapOS ...@@ -233,24 +121,6 @@ class TestSlapOSCrmTriggerEscalationOnAcknowledgmentRegularisationRequest(SlapOS
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_triggerAcknowledgmentEscalation(self):
script_name = 'RegularisationRequest_triggerAcknowledgmentEscalation'
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 RegularisationRequest_triggerAcknowledgmentEscalation') """ )
transaction.commit()
def _dropRegularisationRequest_triggerAcknowledgmentEscalation(self):
script_name = 'RegularisationRequest_triggerAcknowledgmentEscalation'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_matching_regularisation_request(self): def test_alarm_matching_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.edit(resource='service_module/slapos_crm_acknowledgement') ticket.edit(resource='service_module/slapos_crm_acknowledgement')
...@@ -258,16 +128,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -258,16 +128,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerAcknowledgmentEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_acknowledgment_escalation
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket,
slapos_crm_trigger_acknowledgment_escalation.activeSense() "RegularisationRequest_triggerAcknowledgmentEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerAcknowledgmentEscalation()
self.assertEqual(
'Visited by RegularisationRequest_triggerAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_suspended(self): def test_alarm_not_suspended(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -275,16 +139,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -275,16 +139,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.validate() ticket.validate()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerAcknowledgmentEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_acknowledgment_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket,
slapos_crm_trigger_acknowledgment_escalation.activeSense() "RegularisationRequest_triggerAcknowledgmentEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerAcknowledgmentEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_expected_resource(self): def test_alarm_not_expected_resource(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -292,21 +151,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -292,21 +151,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerAcknowledgmentEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_acknowledgment_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket,
slapos_crm_trigger_acknowledgment_escalation.activeSense() "RegularisationRequest_triggerAcknowledgmentEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerAcknowledgmentEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -316,24 +166,6 @@ class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(SlapOSTe ...@@ -316,24 +166,6 @@ class TestSlapOSCrmTriggerEscalationOnStopReminderRegularisationRequest(SlapOSTe
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_triggerStopReminderEscalation(self):
script_name = 'RegularisationRequest_triggerStopReminderEscalation'
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 RegularisationRequest_triggerStopReminderEscalation') """ )
transaction.commit()
def _dropRegularisationRequest_triggerStopReminderEscalation(self):
script_name = 'RegularisationRequest_triggerStopReminderEscalation'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_matching_regularisation_request(self): def test_alarm_matching_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.edit(resource='service_module/slapos_crm_stop_reminder') ticket.edit(resource='service_module/slapos_crm_stop_reminder')
...@@ -341,16 +173,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -341,16 +173,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerStopReminderEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_stop_reminder_escalation
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket,
slapos_crm_trigger_stop_reminder_escalation.activeSense() "RegularisationRequest_triggerStopReminderEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerStopReminderEscalation()
self.assertEqual(
'Visited by RegularisationRequest_triggerStopReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_suspended(self): def test_alarm_not_suspended(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -358,16 +184,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -358,16 +184,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.validate() ticket.validate()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerStopReminderEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_stop_reminder_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket,
slapos_crm_trigger_stop_reminder_escalation.activeSense() "RegularisationRequest_triggerStopReminderEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerStopReminderEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerStopReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_expected_resource(self): def test_alarm_not_expected_resource(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -375,21 +195,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -375,21 +195,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerStopReminderEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_stop_reminder_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket,
slapos_crm_trigger_stop_reminder_escalation.activeSense() "RegularisationRequest_triggerStopReminderEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerStopReminderEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerStopReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(SlapOSTestCaseMixin): class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -399,24 +210,6 @@ class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(Sl ...@@ -399,24 +210,6 @@ class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(Sl
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_triggerStopAcknowledgmentEscalation(self):
script_name = 'RegularisationRequest_triggerStopAcknowledgmentEscalation'
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 RegularisationRequest_triggerStopAcknowledgmentEscalation') """ )
transaction.commit()
def _dropRegularisationRequest_triggerStopAcknowledgmentEscalation(self):
script_name = 'RegularisationRequest_triggerStopAcknowledgmentEscalation'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_matching_regularisation_request(self): def test_alarm_matching_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.edit(resource='service_module/slapos_crm_stop_acknowledgement') ticket.edit(resource='service_module/slapos_crm_stop_acknowledgement')
...@@ -424,16 +217,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -424,16 +217,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerStopAcknowledgmentEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_stop_acknowledgment_escalation
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket,
slapos_crm_trigger_stop_acknowledgment_escalation.activeSense() "RegularisationRequest_triggerStopAcknowledgmentEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerStopAcknowledgmentEscalation()
self.assertEqual(
'Visited by RegularisationRequest_triggerStopAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_suspended(self): def test_alarm_not_suspended(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -441,16 +228,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -441,16 +228,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.validate() ticket.validate()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerStopAcknowledgmentEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_stop_acknowledgment_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket,
slapos_crm_trigger_stop_acknowledgment_escalation.activeSense() "RegularisationRequest_triggerStopAcknowledgmentEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerStopAcknowledgmentEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerStopAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_expected_resource(self): def test_alarm_not_expected_resource(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -458,21 +239,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -458,21 +239,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerStopAcknowledgmentEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_stop_acknowledgment_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket,
slapos_crm_trigger_stop_acknowledgment_escalation.activeSense() "RegularisationRequest_triggerStopAcknowledgmentEscalation")
self.tic()
finally:
self._dropRegularisationRequest_triggerStopAcknowledgmentEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerStopAcknowledgmentEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -482,24 +254,6 @@ class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(SlapOS ...@@ -482,24 +254,6 @@ class TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest(SlapOS
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_triggerDeleteReminderEscalation(self):
script_name = 'RegularisationRequest_triggerDeleteReminderEscalation'
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 RegularisationRequest_triggerDeleteReminderEscalation') """ )
transaction.commit()
def _dropRegularisationRequest_triggerDeleteReminderEscalation(self):
script_name = 'RegularisationRequest_triggerDeleteReminderEscalation'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_matching_regularisation_request(self): def test_alarm_matching_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.edit(resource='service_module/slapos_crm_delete_reminder') ticket.edit(resource='service_module/slapos_crm_delete_reminder')
...@@ -507,16 +261,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -507,16 +261,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerDeleteReminderEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_delete_reminder_escalation
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket, "RegularisationRequest_triggerDeleteReminderEscalation")
slapos_crm_trigger_delete_reminder_escalation.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_triggerDeleteReminderEscalation()
self.assertEqual(
'Visited by RegularisationRequest_triggerDeleteReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_suspended(self): def test_alarm_not_suspended(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -524,16 +271,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -524,16 +271,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.validate() ticket.validate()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerDeleteReminderEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_delete_reminder_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_triggerDeleteReminderEscalation")
slapos_crm_trigger_delete_reminder_escalation.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_triggerDeleteReminderEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerDeleteReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_expected_resource(self): def test_alarm_not_expected_resource(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -541,21 +282,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -541,21 +282,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_triggerDeleteReminderEscalation() alarm = self.portal.portal_alarms.\
try: slapos_crm_trigger_delete_reminder_escalation
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_triggerDeleteReminderEscalation")
slapos_crm_trigger_delete_reminder_escalation.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_triggerDeleteReminderEscalation()
self.assertNotEqual(
'Visited by RegularisationRequest_triggerDeleteReminderEscalation',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmStopHostingSubscription(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlapOSCrmStopHostingSubscription(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -565,24 +296,6 @@ class TestSlapOSCrmStopHostingSubscription(SlapOSTestCaseMixin): ...@@ -565,24 +296,6 @@ class TestSlapOSCrmStopHostingSubscription(SlapOSTestCaseMixin):
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_stopHostingSubscriptionList(self):
script_name = 'RegularisationRequest_stopHostingSubscriptionList'
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 RegularisationRequest_stopHostingSubscriptionList') """ )
transaction.commit()
def _dropRegularisationRequest_stopHostingSubscriptionList(self):
script_name = 'RegularisationRequest_stopHostingSubscriptionList'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_matching_regularisation_request(self): def test_alarm_matching_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.edit(resource='service_module/slapos_crm_delete_reminder') ticket.edit(resource='service_module/slapos_crm_delete_reminder')
...@@ -590,16 +303,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -590,16 +303,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_stopHostingSubscriptionList() alarm = self.portal.portal_alarms.\
try: slapos_crm_stop_hosting_subscription
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket, "RegularisationRequest_stopHostingSubscriptionList")
slapos_crm_stop_hosting_subscription.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_stopHostingSubscriptionList()
self.assertEqual(
'Visited by RegularisationRequest_stopHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_matching_regularisation_request_2(self): def test_alarm_matching_regularisation_request_2(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -608,16 +314,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -608,16 +314,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_stopHostingSubscriptionList() alarm = self.portal.portal_alarms.\
try: slapos_crm_stop_hosting_subscription
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket, "RegularisationRequest_stopHostingSubscriptionList")
slapos_crm_stop_hosting_subscription.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_stopHostingSubscriptionList()
self.assertEqual(
'Visited by RegularisationRequest_stopHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_suspended(self): def test_alarm_not_suspended(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -625,16 +324,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -625,16 +324,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.validate() ticket.validate()
self.tic() self.tic()
self._simulateRegularisationRequest_stopHostingSubscriptionList() alarm = self.portal.portal_alarms.\
try: slapos_crm_stop_hosting_subscription
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_stopHostingSubscriptionList")
slapos_crm_stop_hosting_subscription.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_stopHostingSubscriptionList()
self.assertNotEqual(
'Visited by RegularisationRequest_stopHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_other_resource(self): def test_alarm_other_resource(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -643,21 +336,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -643,21 +336,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_stopHostingSubscriptionList() alarm = self.portal.portal_alarms.\
try: slapos_crm_stop_hosting_subscription
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_stopHostingSubscriptionList")
slapos_crm_stop_hosting_subscription.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_stopHostingSubscriptionList()
self.assertNotEqual(
'Visited by RegularisationRequest_stopHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmDeleteHostingSubscription(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlapOSCrmDeleteHostingSubscription(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -667,24 +351,6 @@ class TestSlapOSCrmDeleteHostingSubscription(SlapOSTestCaseMixin): ...@@ -667,24 +351,6 @@ class TestSlapOSCrmDeleteHostingSubscription(SlapOSTestCaseMixin):
reference="TESTREGREQ-%s" % new_id, reference="TESTREGREQ-%s" % new_id,
) )
def _simulateRegularisationRequest_deleteHostingSubscriptionList(self):
script_name = 'RegularisationRequest_deleteHostingSubscriptionList'
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 RegularisationRequest_deleteHostingSubscriptionList') """ )
transaction.commit()
def _dropRegularisationRequest_deleteHostingSubscriptionList(self):
script_name = 'RegularisationRequest_deleteHostingSubscriptionList'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_matching_regularisation_request(self): def test_alarm_matching_regularisation_request(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.edit(resource='service_module/slapos_crm_delete_acknowledgement') ticket.edit(resource='service_module/slapos_crm_delete_acknowledgement')
...@@ -692,16 +358,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -692,16 +358,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_deleteHostingSubscriptionList() alarm = self.portal.portal_alarms.\
try: slapos_crm_delete_hosting_subscription
self.portal.portal_alarms.\ self._test_alarm(alarm, ticket, "RegularisationRequest_deleteHostingSubscriptionList")
slapos_crm_delete_hosting_subscription.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_deleteHostingSubscriptionList()
self.assertEqual(
'Visited by RegularisationRequest_deleteHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_suspended(self): def test_alarm_not_suspended(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -709,16 +368,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -709,16 +368,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.validate() ticket.validate()
self.tic() self.tic()
self._simulateRegularisationRequest_deleteHostingSubscriptionList() alarm = self.portal.portal_alarms.\
try: slapos_crm_delete_hosting_subscription
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_deleteHostingSubscriptionList")
slapos_crm_delete_hosting_subscription.activeSense()
self.tic()
finally:
self._dropRegularisationRequest_deleteHostingSubscriptionList()
self.assertNotEqual(
'Visited by RegularisationRequest_deleteHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_other_resource(self): def test_alarm_other_resource(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
...@@ -727,105 +380,51 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R ...@@ -727,105 +380,51 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
ticket.suspend() ticket.suspend()
self.tic() self.tic()
self._simulateRegularisationRequest_deleteHostingSubscriptionList() alarm = self.portal.portal_alarms.\
try: slapos_crm_delete_hosting_subscription
self.portal.portal_alarms.\ self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_deleteHostingSubscriptionList")
slapos_crm_delete_hosting_subscription.activeSense()
self.tic()
finally: class TestSlapOSCrmMonitoringCheckComputerState(SlapOSTestCaseMixinWithAbort):
self._dropRegularisationRequest_deleteHostingSubscriptionList()
self.assertNotEqual(
'Visited by RegularisationRequest_deleteHostingSubscriptionList',
ticket.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckComputerState(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
def _simulateComputer_checkState(self):
script_name = 'Computer_checkState'
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, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Computer_checkState') """ )
transaction.commit()
def _dropComputer_checkState(self):
script_name = 'Computer_checkState'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_check_public_computer_state(self): def test_alarm_check_public_computer_state(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope='open/public') self.computer.edit(allocation_scope='open/public')
self.tic() self.tic()
self.assertEqual(self.computer.getMonitorScope(), "enabled") self.assertEqual(self.computer.getMonitorScope(), "enabled")
self._simulateComputer_checkState()
self.tic()
try:
self.portal.portal_alarms.slapos_crm_check_computer_state.activeSense()
self.tic() self.tic()
finally: alarm = self.portal.portal_alarms.\
self._dropComputer_checkState() slapos_crm_check_computer_state
self._test_alarm(alarm, self.computer, "Computer_checkState")
self.assertEqual('Visited by Computer_checkState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_check_friend_computer_state(self): def test_alarm_check_friend_computer_state(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope='open/friend') self.computer.edit(allocation_scope='open/friend')
self.tic() self.tic()
self._simulateComputer_checkState() alarm = self.portal.portal_alarms.\
slapos_crm_check_computer_state
try: self._test_alarm(alarm, self.computer, "Computer_checkState")
self.portal.portal_alarms.slapos_crm_check_computer_state.activeSense()
self.tic()
finally:
self._dropComputer_checkState()
self.assertEqual('Visited by Computer_checkState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_check_personal_computer_state(self): def test_alarm_check_personal_computer_state(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope='open/personal') self.computer.edit(allocation_scope='open/personal')
self.tic() self.tic()
self._simulateComputer_checkState() alarm = self.portal.portal_alarms.\
slapos_crm_check_computer_state
try: self._test_alarm(alarm, self.computer, "Computer_checkState")
self.portal.portal_alarms.slapos_crm_check_computer_state.activeSense()
self.tic()
finally:
self._dropComputer_checkState()
self.assertEqual('Visited by Computer_checkState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def _test_alarm_check_computer_state_not_selected(self, allocation_scope, def _test_alarm_check_computer_state_not_selected(self, allocation_scope,
monitor_scope=None): monitor_scope=None):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope=allocation_scope) self.computer.edit(allocation_scope=allocation_scope)
self.tic() self.tic()
self._simulateComputer_checkState()
if monitor_scope is not None: if monitor_scope is not None:
self.computer.edit(monitor_scope=monitor_scope) self.computer.edit(monitor_scope=monitor_scope)
self.tic() self.tic()
try: alarm = self.portal.portal_alarms.\
self.portal.portal_alarms.slapos_crm_check_computer_state.activeSense() slapos_crm_check_computer_state
self.tic() self._test_alarm_not_visited(alarm, self.computer, "Computer_checkState")
finally:
self._dropComputer_checkState()
self.assertNotEqual('Visited by Computer_checkState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_check_computer_state_on_public_computer_with_monitor_scope_disabled(self): def test_alarm_check_computer_state_on_public_computer_with_monitor_scope_disabled(self):
self._test_alarm_check_computer_state_not_selected( self._test_alarm_check_computer_state_not_selected(
...@@ -855,144 +454,60 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -855,144 +454,60 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
allocation_scope='closed/termination') allocation_scope='closed/termination')
class TestSlapOSCrmMonitoringCheckComputerAllocationScope(SlapOSTestCaseMixin): class TestSlapOSCrmMonitoringCheckComputerAllocationScope(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def _simulateComputer_checkAndUpdateAllocationScope(self):
script_name = 'Computer_checkAndUpdateAllocationScope'
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, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Computer_checkAndUpdateAllocationScope') """ )
transaction.commit()
def _dropComputer_checkAndUpdateAllocationScope(self):
script_name = 'Computer_checkAndUpdateAllocationScope'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_not_allowed_allocation_scope_OpenPublic(self): def test_alarm_not_allowed_allocation_scope_OpenPublic(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/public') self.computer.edit(allocation_scope = 'open/public')
self._simulateComputer_checkAndUpdateAllocationScope()
try:
self.portal.portal_alarms.slapos_crm_check_update_allocation_scope.activeSense()
self.tic() self.tic()
finally: alarm = self.portal.portal_alarms.\
self._dropComputer_checkAndUpdateAllocationScope() slapos_crm_check_update_allocation_scope
self._test_alarm(alarm, self.computer, "Computer_checkAndUpdateAllocationScope")
self.assertEqual('Visited by Computer_checkAndUpdateAllocationScope',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_allowed_allocation_scope_OpenFriend(self): def test_alarm_not_allowed_allocation_scope_OpenFriend(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/friend') self.computer.edit(allocation_scope = 'open/friend')
self._simulateComputer_checkAndUpdateAllocationScope()
try:
self.portal.portal_alarms.slapos_crm_check_update_allocation_scope.activeSense()
self.tic() self.tic()
finally: alarm = self.portal.portal_alarms.\
self._dropComputer_checkAndUpdateAllocationScope() slapos_crm_check_update_allocation_scope
self._test_alarm(alarm, self.computer, "Computer_checkAndUpdateAllocationScope")
self.assertEqual('Visited by Computer_checkAndUpdateAllocationScope',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_allowed_allocationScope_open_personal(self): def test_alarm_not_allowed_allocationScope_open_personal(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/personal') self.computer.edit(allocation_scope = 'open/personal')
self._simulateComputer_checkAndUpdateAllocationScope()
self.tic()
try:
self.portal.portal_alarms.slapos_crm_check_update_allocation_scope.activeSense()
self.tic() self.tic()
finally: alarm = self.portal.portal_alarms.\
self._dropComputer_checkAndUpdateAllocationScope() slapos_crm_check_update_allocation_scope
self._test_alarm_not_visited(alarm, self.computer, "Computer_checkAndUpdateAllocationScope")
self.assertNotEqual('Visited by Computer_checkAndUpdateAllocationScope', class TestSlapOSCrmMonitoringCheckComputerSoftwareInstallation(SlapOSTestCaseMixinWithAbort):
self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckComputerSoftwareInstallation(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
def _simulateComputer_checkSoftwareInstallationState(self):
script_name = 'Computer_checkSoftwareInstallationState'
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, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Computer_checkSoftwareInstallationState') """ )
transaction.commit()
def _dropComputer_checkSoftwareInstallationState(self):
script_name = 'Computer_checkSoftwareInstallationState'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_run_on_open_public(self): def test_alarm_run_on_open_public(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/public') self.computer.edit(allocation_scope = 'open/public')
self.tic() self.tic()
self._simulateComputer_checkSoftwareInstallationState() alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
try: self._test_alarm(alarm, self.computer, "Computer_checkSoftwareInstallationState")
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_run_on_open_friend(self): def test_alarm_run_on_open_friend(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/friend') self.computer.edit(allocation_scope = 'open/friend')
self.tic() self.tic()
self._simulateComputer_checkSoftwareInstallationState() alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
try: self._test_alarm(alarm, self.computer, "Computer_checkSoftwareInstallationState")
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_run_on_open_personal(self): def test_alarm_run_on_open_personal(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/personal', self.computer.edit(allocation_scope = 'open/personal',
monitor_scope="enabled") monitor_scope="enabled")
self.tic() self.tic()
self._simulateComputer_checkSoftwareInstallationState() alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
try: self._test_alarm(alarm, self.computer, "Computer_checkSoftwareInstallationState")
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_dont_run_on_open_public_with_monitor_scope_disabled(self): def test_alarm_dont_run_on_open_public_with_monitor_scope_disabled(self):
self._makeComputer() self._makeComputer()
...@@ -1000,142 +515,52 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1000,142 +515,52 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.tic() self.tic()
self.computer.edit(monitor_scope = 'disabled') self.computer.edit(monitor_scope = 'disabled')
self.tic() self.tic()
self._simulateComputer_checkSoftwareInstallationState() alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
try: self._test_alarm_not_visited(alarm, self.computer, "Computer_checkSoftwareInstallationState")
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertNotEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_dont_run_on_open_friend_with_monitor_scope_disabled(self): def test_alarm_dont_run_on_open_friend_with_monitor_scope_disabled(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/friend') self.computer.edit(allocation_scope = 'open/friend')
self.tic() self.tic()
self._simulateComputer_checkSoftwareInstallationState()
self.computer.edit(monitor_scope = 'disabled') self.computer.edit(monitor_scope = 'disabled')
self.tic() self.tic()
alarm = self.portal.portal_alarms.\
try: slapos_crm_check_software_installation_state
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense() self._test_alarm_not_visited(alarm, self.computer, "Computer_checkSoftwareInstallationState")
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertNotEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_dont_run_on_open_personal_with_monitor_scope_disabled(self): def test_alarm_dont_run_on_open_personal_with_monitor_scope_disabled(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/personal', self.computer.edit(allocation_scope = 'open/personal',
monitor_scope="enabled") monitor_scope="enabled")
self.tic() self.tic()
self._simulateComputer_checkSoftwareInstallationState()
self.computer.edit(monitor_scope = 'disabled') self.computer.edit(monitor_scope = 'disabled')
self.tic() self.tic()
alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
self._test_alarm_not_visited(alarm, self.computer, "Computer_checkSoftwareInstallationState")
try: def _test_alarm_not_run_on_close(self, allocation_scope):
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertNotEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_run_on_close_forever(self):
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'close/forever') self.computer.edit(allocation_scope=allocation_scope)
self.tic()
self._simulateComputer_checkSoftwareInstallationState()
try:
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic() self.tic()
finally: alarm = self.portal.portal_alarms.\
self._dropComputer_checkSoftwareInstallationState() slapos_crm_check_software_installation_state
self._test_alarm_not_visited(alarm, self.computer, "Computer_checkSoftwareInstallationState")
self.assertNotEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_run_on_close_forever(self):
self._test_alarm_not_run_on_close('close/forever')
def test_alarm_not_run_on_close_maintainence(self): def test_alarm_not_run_on_close_maintainence(self):
self._makeComputer() self._test_alarm_not_run_on_close('close/maintenence')
self.computer.edit(allocation_scope = 'close/maintenence')
self.tic()
self._simulateComputer_checkSoftwareInstallationState()
try:
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertNotEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_run_on_close_outdated(self): def test_alarm_not_run_on_close_outdated(self):
self._makeComputer() self._test_alarm_not_run_on_close('close/outdated')
self.computer.edit(allocation_scope = 'close/outdated')
self.tic()
self._simulateComputer_checkSoftwareInstallationState()
try:
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertNotEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_run_on_close_termination(self): def test_alarm_not_run_on_close_termination(self):
self._makeComputer() self._test_alarm_not_run_on_close('close/termination')
self.computer.edit(allocation_scope = 'close/termination')
self.tic()
self._simulateComputer_checkSoftwareInstallationState()
try:
self.portal.portal_alarms.slapos_crm_check_software_installation_state.activeSense()
self.tic()
finally:
self._dropComputer_checkSoftwareInstallationState()
self.assertNotEqual('Visited by Computer_checkSoftwareInstallationState',
self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckComputerPersonalAllocationScope(SlapOSTestCaseMixinWithAbort):
class TestSlapOSCrmMonitoringCheckComputerPersonalAllocationScope(SlapOSTestCaseMixin):
def beforeTearDown(self):
transaction.abort()
def _simulateComputer_checkAndUpdatePersonalAllocationScope(self):
script_name = 'Computer_checkAndUpdatePersonalAllocationScope'
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, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Computer_checkAndUpdatePersonalAllocationScope') """ )
transaction.commit()
def _dropComputer_checkAndUpdatePersonalAllocationScope(self):
script_name = 'Computer_checkAndUpdatePersonalAllocationScope'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_allowed_allocation_scope_OpenPersonal_old_computer(self): def test_alarm_allowed_allocation_scope_OpenPersonal_old_computer(self):
self._makeComputer() self._makeComputer()
...@@ -1145,7 +570,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1145,7 +570,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
self._simulateComputer_checkAndUpdatePersonalAllocationScope() self._simulateScript("Computer_checkAndUpdatePersonalAllocationScope")
original_get_creation = Base.getCreationDate original_get_creation = Base.getCreationDate
Base.getCreationDate = getCreationDate Base.getCreationDate = getCreationDate
...@@ -1156,7 +581,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1156,7 +581,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.tic() self.tic()
finally: finally:
Base.getCreationDate = original_get_creation Base.getCreationDate = original_get_creation
self._dropComputer_checkAndUpdatePersonalAllocationScope() self._dropScript('Computer_checkAndUpdatePersonalAllocationScope')
self.assertEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope', self.assertEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope',
self.computer.workflow_history['edit_workflow'][-1]['comment']) self.computer.workflow_history['edit_workflow'][-1]['comment'])
...@@ -1170,7 +595,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1170,7 +595,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
self._simulateComputer_checkAndUpdatePersonalAllocationScope() self._simulateScript("Computer_checkAndUpdatePersonalAllocationScope")
original_get_creation = Base.getCreationDate original_get_creation = Base.getCreationDate
Base.getCreationDate = getCreationDate Base.getCreationDate = getCreationDate
...@@ -1179,7 +604,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1179,7 +604,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.tic() self.tic()
finally: finally:
Base.getCreationDate = original_get_creation Base.getCreationDate = original_get_creation
self._dropComputer_checkAndUpdatePersonalAllocationScope() self._dropScript('Computer_checkAndUpdatePersonalAllocationScope')
self.assertNotEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope', self.assertNotEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope',
self.computer.workflow_history['edit_workflow'][-1]['comment']) self.computer.workflow_history['edit_workflow'][-1]['comment'])
...@@ -1188,21 +613,18 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -1188,21 +613,18 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self._makeComputer() self._makeComputer()
self.computer.edit(allocation_scope = 'open/oudated') self.computer.edit(allocation_scope = 'open/oudated')
self._simulateComputer_checkAndUpdatePersonalAllocationScope() self._simulateScript("Computer_checkAndUpdatePersonalAllocationScope")
try: try:
self.portal.portal_alarms.slapos_crm_check_update_personal_allocation_scope.activeSense() self.portal.portal_alarms.slapos_crm_check_update_personal_allocation_scope.activeSense()
self.tic() self.tic()
finally: finally:
self._dropComputer_checkAndUpdatePersonalAllocationScope() self._dropScript('Computer_checkAndUpdatePersonalAllocationScope')
self.assertNotEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope', self.assertNotEqual('Visited by Computer_checkAndUpdatePersonalAllocationScope',
self.computer.workflow_history['edit_workflow'][-1]['comment']) self.computer.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixin): class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
def beforeTearDown(self):
transaction.abort()
def _makeHostingSubscription(self): def _makeHostingSubscription(self):
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
...@@ -1235,50 +657,20 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixin): ...@@ -1235,50 +657,20 @@ class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixin):
hosting_subscription.requestStart(**kw) hosting_subscription.requestStart(**kw)
hosting_subscription.requestInstance(**kw) hosting_subscription.requestInstance(**kw)
def _simulateHostingSubscription_checkSoftwareInstanceState(self):
script_name = 'HostingSubscription_checkSoftwareInstanceState'
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, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by HostingSubscription_checkSoftwareInstanceState') """ )
transaction.commit()
def _dropHostingSubscription_checkSoftwareInstanceState(self):
script_name = 'HostingSubscription_checkSoftwareInstanceState'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_check_instance_in_error_validated_hosting_subscription(self): def test_alarm_check_instance_in_error_validated_hosting_subscription(self):
host_sub = self._makeHostingSubscription() host_sub = self._makeHostingSubscription()
self.tic() self.tic()
alarm = self.portal.portal_alarms.\
self._simulateHostingSubscription_checkSoftwareInstanceState() slapos_crm_check_instance_in_error
self._test_alarm(alarm, host_sub, "HostingSubscription_checkSoftwareInstanceState")
try:
self.portal.portal_alarms.slapos_crm_check_instance_in_error.activeSense()
self.tic()
finally:
self._dropHostingSubscription_checkSoftwareInstanceState()
self.assertEqual('Visited by HostingSubscription_checkSoftwareInstanceState',
host_sub.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_check_instance_in_error_validated_hosting_subscription_with_monitor_disabled(self): def test_alarm_check_instance_in_error_validated_hosting_subscription_with_monitor_disabled(self):
host_sub = self._makeHostingSubscription() host_sub = self._makeHostingSubscription()
host_sub.edit(monitor_scope="disabled") host_sub.edit(monitor_scope="disabled")
self.tic() self.tic()
self._simulateHostingSubscription_checkSoftwareInstanceState() alarm = self.portal.portal_alarms.\
slapos_crm_check_instance_in_error
try: self._test_alarm(alarm, host_sub, "HostingSubscription_checkSoftwareInstanceState")
self.portal.portal_alarms.slapos_crm_check_instance_in_error.activeSense()
self.tic()
finally:
self._dropHostingSubscription_checkSoftwareInstanceState()
# This is an un-optimal case, as the query cannot be used in negated form # This is an un-optimal case, as the query cannot be used in negated form
# on the searchAndActivate, so we end up callind the script in any situation. # on the searchAndActivate, so we end up callind the script in any situation.
...@@ -1288,22 +680,13 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H ...@@ -1288,22 +680,13 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
def test_alarm_check_instance_in_error_archived_hosting_subscription(self): def test_alarm_check_instance_in_error_archived_hosting_subscription(self):
host_sub = self._makeHostingSubscription() host_sub = self._makeHostingSubscription()
host_sub.archive() host_sub.archive()
self._simulateHostingSubscription_checkSoftwareInstanceState()
try:
self.portal.portal_alarms.slapos_crm_check_instance_in_error.activeSense()
self.tic() self.tic()
finally: alarm = self.portal.portal_alarms.\
self._dropHostingSubscription_checkSoftwareInstanceState() slapos_crm_check_instance_in_error
self._test_alarm_not_visited(alarm, host_sub, "HostingSubscription_checkSoftwareInstanceState")
self.assertNotEqual('Visited by HostingSubscription_checkSoftwareInstanceState',
host_sub.workflow_history['edit_workflow'][-1]['comment'])
class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixin):
def beforeTearDown(self): class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort):
transaction.abort()
def _makeSupportRequest(self): def _makeSupportRequest(self):
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
...@@ -1314,7 +697,7 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixin): ...@@ -1314,7 +697,7 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixin):
support_request.validate() support_request.validate()
new_id = self.generateNewId() new_id = self.generateNewId()
support_request.edit( support_request.edit(
title= "Support Request éçà %s" % new_id, title= "Support Request éçà %s" % new_id, #pylint: disable=invalid-encoded-data
reference="TESTSRQ-%s" % new_id, reference="TESTSRQ-%s" % new_id,
destination_decision_value=person destination_decision_value=person
) )
...@@ -1338,45 +721,11 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixin): ...@@ -1338,45 +721,11 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixin):
return hosting_subscription return hosting_subscription
def _simulateSupportRequest_updateMonitoringState(self):
script_name = 'SupportRequest_updateMonitoringState'
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, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by SupportRequest_updateMonitoringState') """ )
transaction.commit()
def _dropSupportRequest_updateMonitoringState(self):
script_name = 'SupportRequest_updateMonitoringState'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_update_support_request_state(self): def test_alarm_update_support_request_state(self):
support_request = self._makeSupportRequest() support_request = self._makeSupportRequest()
hs = self._makeHostingSubscription() hs = self._makeHostingSubscription()
support_request.setAggregateValue(hs) support_request.setAggregateValue(hs)
self.tic() self.tic()
alarm = self.portal.portal_alarms.\
self._simulateSupportRequest_updateMonitoringState() slapos_crm_update_support_request_state
self._test_alarm(alarm, support_request, "SupportRequest_updateMonitoringState")
try:
self.portal.portal_alarms.slapos_crm_update_support_request_state.activeSense()
self.tic()
finally:
self._dropSupportRequest_updateMonitoringState()
self.assertEqual('Visited by SupportRequest_updateMonitoringState',
support_request.workflow_history['edit_workflow'][-1]['comment'])
...@@ -45,10 +45,7 @@ ...@@ -45,10 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:1317, 0: Cannot decode using encoding "ascii", unexpected byte at position 32 (invalid-encoded-data)</string>
<string>W: 3, 0: Unused simulate imported from erp5.component.test.SlapOSTestCaseMixin (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -103,11 +100,13 @@ ...@@ -103,11 +100,13 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -120,7 +119,9 @@ ...@@ -120,7 +119,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -147,7 +147,7 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin): ...@@ -147,7 +147,7 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin):
monitor_url_temp_document_list = module.SupportRequestModule_getMonitoringUrlList() monitor_url_temp_document_list = module.SupportRequestModule_getMonitoringUrlList()
self.assertEqual(len(monitor_url_temp_document_list), 1) self.assertEqual(len(monitor_url_temp_document_list), 1)
self.assertEqual(monitor_url_temp_document_list[0].getTitle(), self.assertEqual(monitor_url_temp_document_list[0].title,
hosting_subscription.getTitle()) hosting_subscription.getTitle())
self.assertEqual(monitor_url_temp_document_list[0].monitor_url, self.assertEqual(monitor_url_temp_document_list[0].monitor_url,
"http://monitor.url/#/ABC") "http://monitor.url/#/ABC")
...@@ -622,15 +622,6 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -622,15 +622,6 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
TestCRMSkinsMixin.afterSetUp(self) TestCRMSkinsMixin.afterSetUp(self)
self._cancelTestSupportRequestList(title="%%TESTCOMPT-%") self._cancelTestSupportRequestList(title="%%TESTCOMPT-%")
def _makeComputer(self):
TestCRMSkinsMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson()
)
return self.computer
def _getGeneratedSupportRequest(self, computer): def _getGeneratedSupportRequest(self, computer):
request_title = '%%We have changed allocation scope for %s' % \ request_title = '%%We have changed allocation scope for %s' % \
computer.getReference() computer.getReference()
...@@ -667,7 +658,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -667,7 +658,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
'%s %s %s" % (message_title, message, destination_relative_url))\n' \ '%s %s %s" % (message_title, message, destination_relative_url))\n' \
'return 1') 'return 1')
def test_computerNotAllowedAllocationScope_OpenPublic(self): def test_computerNotAllowedAllocationScope_OpenPublic(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
self.portal.REQUEST['test_computerNotAllowedAllocationScope_OpenPublic'] = \ self.portal.REQUEST['test_computerNotAllowedAllocationScope_OpenPublic'] = \
...@@ -703,7 +694,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -703,7 +694,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
'%s %s %s" % (message_title, message, destination_relative_url))\n' \ '%s %s %s" % (message_title, message, destination_relative_url))\n' \
'return 1') 'return 1')
def test_computerNotAllowedAllocationScope_OpenFriend(self): def test_computerNotAllowedAllocationScope_OpenFriend(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
self.portal.REQUEST['test_computerNotAllowedAllocationScope_OpenFriend'] = \ self.portal.REQUEST['test_computerNotAllowedAllocationScope_OpenFriend'] = \
...@@ -738,7 +729,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -738,7 +729,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
'%s %s %s" % (message_title, message, destination_relative_url))\n' \ '%s %s %s" % (message_title, message, destination_relative_url))\n' \
'return 1') 'return 1')
def test_computerToCloseAllocationScope_OpenPersonal(self): def test_computerToCloseAllocationScope_OpenPersonal(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
target_allocation_scope = 'close/outdated' target_allocation_scope = 'close/outdated'
...@@ -759,7 +750,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -759,7 +750,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
support_request.workflow_history['edit_workflow'][-1]['comment']) support_request.workflow_history['edit_workflow'][-1]['comment'])
def test_computerNormalAllocationScope_OpenPersonal(self): def test_computerNormalAllocationScope_OpenPersonal(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider') self._updatePersonAssignment(person, 'role/service_provider')
...@@ -769,7 +760,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -769,7 +760,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
self.assertEqual(computer.getAllocationScope(), 'open/personal') self.assertEqual(computer.getAllocationScope(), 'open/personal')
def test_computerAllowedAllocationScope_OpenPublic(self): def test_computerAllowedAllocationScope_OpenPublic(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider') self._updatePersonAssignment(person, 'role/service_provider')
...@@ -779,7 +770,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -779,7 +770,7 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
self.assertEqual(computer.getAllocationScope(), 'open/public') self.assertEqual(computer.getAllocationScope(), 'open/public')
def test_computerAllowedAllocationScope_OpenFriend(self): def test_computerAllowedAllocationScope_OpenFriend(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
friend_person = self.makePerson() friend_person = self.makePerson()
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider') self._updatePersonAssignment(person, 'role/service_provider')
...@@ -793,10 +784,6 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -793,10 +784,6 @@ class TestSlapOSComputer_notifyWrongAllocationScope(TestCRMSkinsMixin):
class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort): class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
def _makeComputer(self):
SlapOSTestCaseMixinWithAbort._makeComputer(self)
return self.computer
def createSPL(self, computer): def createSPL(self, computer):
delivery_template = self.portal.restrictedTraverse( delivery_template = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredInstanceDeliveryTemplate()) self.portal.portal_preferences.getPreferredInstanceDeliveryTemplate())
...@@ -820,14 +807,14 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort): ...@@ -820,14 +807,14 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
return delivery return delivery
def test_Computer_hasContactedRecently_newly_created(self): def test_Computer_hasContactedRecently_newly_created(self):
computer = self._makeComputer() computer = self._makeComputer()[0]
self.tic() self.tic()
has_contacted = computer.Computer_hasContactedRecently() has_contacted = computer.Computer_hasContactedRecently()
self.assertTrue(has_contacted) self.assertTrue(has_contacted)
@simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32') @simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32')
def test_Computer_hasContactedRecently_no_data(self): def test_Computer_hasContactedRecently_no_data(self):
computer = self._makeComputer() computer = self._makeComputer()[0]
self.tic() self.tic()
computer.getCreationDate = self.portal.Computer_getCreationDate computer.getCreationDate = self.portal.Computer_getCreationDate
...@@ -836,7 +823,7 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort): ...@@ -836,7 +823,7 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
@simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32') @simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32')
def test_Computer_hasContactedRecently_memcached(self): def test_Computer_hasContactedRecently_memcached(self):
computer = self._makeComputer() computer = self._makeComputer()[0]
memcached_dict = self.portal.portal_memcached.getMemcachedDict( memcached_dict = self.portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool', key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin') plugin_path='portal_memcached/default_memcached_plugin')
...@@ -853,7 +840,7 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort): ...@@ -853,7 +840,7 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
@simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32') @simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32')
def test_Computer_hasContactedRecently_memcached_oudated_no_spl(self): def test_Computer_hasContactedRecently_memcached_oudated_no_spl(self):
computer = self._makeComputer() computer = self._makeComputer()[0]
memcached_dict = self.portal.portal_memcached.getMemcachedDict( memcached_dict = self.portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool', key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin') plugin_path='portal_memcached/default_memcached_plugin')
...@@ -870,7 +857,7 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort): ...@@ -870,7 +857,7 @@ class TestComputer_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
@simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32') @simulate('Computer_getCreationDate', '*args, **kwargs','return DateTime() - 32')
def test_Computer_hasContactedRecently_memcached_oudated_with_spl(self): def test_Computer_hasContactedRecently_memcached_oudated_with_spl(self):
computer = self._makeComputer() computer = self._makeComputer()[0]
memcached_dict = self.portal.portal_memcached.getMemcachedDict( memcached_dict = self.portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool', key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin') plugin_path='portal_memcached/default_memcached_plugin')
...@@ -1009,14 +996,6 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -1009,14 +996,6 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
self.tic() self.tic()
self._cancelTestSupportRequestList() self._cancelTestSupportRequestList()
def _makeComputer(self):
SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson(user=0)
)
return self.computer
def test_computer_Base_generateSupportRequestForSlapOS(self): def test_computer_Base_generateSupportRequestForSlapOS(self):
self._makeComputer() self._makeComputer()
title = "Test Support Request %s" % self.computer.getReference() title = "Test Support Request %s" % self.computer.getReference()
...@@ -1115,7 +1094,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -1115,7 +1094,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
def test_Base_generateSupportRequestForSlapOS_do_not_recreate_if_open(self): def test_Base_generateSupportRequestForSlapOS_do_not_recreate_if_open(self):
self._makeComputer() self._makeComputer(owner=self.makePerson(user=0))
title = "Test Support Request %s" % self.computer.getReference() title = "Test Support Request %s" % self.computer.getReference()
support_request = self.computer.Base_generateSupportRequestForSlapOS( support_request = self.computer.Base_generateSupportRequestForSlapOS(
title, title, self.computer.getRelativeUrl() title, title, self.computer.getRelativeUrl()
...@@ -1131,7 +1110,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -1131,7 +1110,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
def test_Base_generateSupportRequestForSlapOS_do_not_recreate_if_suspended(self): def test_Base_generateSupportRequestForSlapOS_do_not_recreate_if_suspended(self):
self._makeComputer() self._makeComputer(owner=self.makePerson(user=0))
title = "Test Support Request %s" % self.computer.getReference() title = "Test Support Request %s" % self.computer.getReference()
support_request = self.computer.Base_generateSupportRequestForSlapOS( support_request = self.computer.Base_generateSupportRequestForSlapOS(
title, title, self.computer.getRelativeUrl() title, title, self.computer.getRelativeUrl()
...@@ -1148,7 +1127,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -1148,7 +1127,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
self.assertEqual(support_request, same_support_request) self.assertEqual(support_request, same_support_request)
def test_Base_generateSupportRequestForSlapOS_recreate_if_closed(self): def test_Base_generateSupportRequestForSlapOS_recreate_if_closed(self):
self._makeComputer() self._makeComputer(owner=self.makePerson(user=0))
title = "Test Support Request %s" % self.computer.getReference() title = "Test Support Request %s" % self.computer.getReference()
support_request = self.computer.Base_generateSupportRequestForSlapOS( support_request = self.computer.Base_generateSupportRequestForSlapOS(
title, title, self.computer.getRelativeUrl()) title, title, self.computer.getRelativeUrl())
...@@ -1167,7 +1146,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -1167,7 +1146,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
self.assertNotEqual(support_request, None) self.assertNotEqual(support_request, None)
def test_Base_generateSupportRequestForSlapOS_recreate(self): def test_Base_generateSupportRequestForSlapOS_recreate(self):
self._makeComputer() self._makeComputer(owner=self.makePerson(user=0))
title = "Test Support Request %s" % self.computer.getRelativeUrl() title = "Test Support Request %s" % self.computer.getRelativeUrl()
support_request = self.computer.Base_generateSupportRequestForSlapOS( support_request = self.computer.Base_generateSupportRequestForSlapOS(
title, title, self.computer.getRelativeUrl()) title, title, self.computer.getRelativeUrl())
...@@ -1179,7 +1158,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -1179,7 +1158,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
self.assertEqual(support_request, same_support_request) self.assertEqual(support_request, same_support_request)
def test_Base_generateSupportRequestForSlapOS_inprogress(self): def test_Base_generateSupportRequestForSlapOS_inprogress(self):
self._makeComputer() self._makeComputer(owner=self.makePerson(user=0))
title = "Test Support Request %s" % self.computer.getRelativeUrl() title = "Test Support Request %s" % self.computer.getRelativeUrl()
support_request = self.computer.Base_generateSupportRequestForSlapOS( support_request = self.computer.Base_generateSupportRequestForSlapOS(
title, title, self.computer.getRelativeUrl()) title, title, self.computer.getRelativeUrl())
...@@ -1229,15 +1208,6 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -1229,15 +1208,6 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
) )
return support_request return support_request
def _makeComputer(self):
TestCRMSkinsMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson(user=0)
)
return self.computer
def _simulateBase_generateSupportRequestForSlapOS(self): def _simulateBase_generateSupportRequestForSlapOS(self):
script_name = 'Base_generateSupportRequestForSlapOS' script_name = 'Base_generateSupportRequestForSlapOS'
if script_name in self.portal.portal_skins.custom.objectIds(): if script_name in self.portal.portal_skins.custom.objectIds():
...@@ -1249,16 +1219,9 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -1249,16 +1219,9 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
"""return context.getPortalObject().REQUEST['_simulateBase_generateSupportRequestForSlapOS']""") """return context.getPortalObject().REQUEST['_simulateBase_generateSupportRequestForSlapOS']""")
transaction.commit() transaction.commit()
def _dropBase_generateSupportRequestForSlapOS(self):
script_name = 'Base_generateSupportRequestForSlapOS'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
self.assertFalse(script_name in self.portal.portal_skins.custom.objectIds())
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0') @simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
def test_Computer_checkState_call_support_request(self): def test_Computer_checkState_call_support_request(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
memcached_dict = self.portal.portal_memcached.getMemcachedDict( memcached_dict = self.portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool', key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin') plugin_path='portal_memcached/default_memcached_plugin')
...@@ -1275,7 +1238,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -1275,7 +1238,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
try: try:
computer_support_request = computer.Computer_checkState() computer_support_request = computer.Computer_checkState()
finally: finally:
self._dropBase_generateSupportRequestForSlapOS() self._dropScript("Base_generateSupportRequestForSlapOS")
self.assertEqual(support_request, self.assertEqual(support_request,
computer_support_request) computer_support_request)
...@@ -1283,7 +1246,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -1283,7 +1246,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0') @simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
def test_Computer_checkState_empty_cache(self): def test_Computer_checkState_empty_cache(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
self._simulateBase_generateSupportRequestForSlapOS() self._simulateBase_generateSupportRequestForSlapOS()
support_request = self._makeSupportRequest() support_request = self._makeSupportRequest()
...@@ -1293,7 +1256,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -1293,7 +1256,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
try: try:
computer_support_request = computer.Computer_checkState() computer_support_request = computer.Computer_checkState()
finally: finally:
self._dropBase_generateSupportRequestForSlapOS() self._dropScript("Base_generateSupportRequestForSlapOS")
self.assertEqual(support_request, self.assertEqual(support_request,
computer_support_request) computer_support_request)
...@@ -1311,7 +1274,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -1311,7 +1274,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
'comment="Visited by SupportRequest_trySendNotificationMessage ' \ 'comment="Visited by SupportRequest_trySendNotificationMessage ' \
'%s %s %s" % (message_title, message, destination_relative_url))') '%s %s %s" % (message_title, message, destination_relative_url))')
def test_Computer_checkState_notify(self): def test_Computer_checkState_notify(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
...@@ -1353,7 +1316,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin): ...@@ -1353,7 +1316,7 @@ class TestSlapOSComputer_CheckState(TestCRMSkinsMixin):
'comment="Visited by SupportRequest_trySendNotificationMessage ' \ 'comment="Visited by SupportRequest_trySendNotificationMessage ' \
'%s %s %s" % (message_title, message, destination_relative_url))') '%s %s %s" % (message_title, message, destination_relative_url))')
def test_Computer_checkState_empty_cache_notify(self): def test_Computer_checkState_empty_cache_notify(self):
computer = self._makeComputer() computer = self._makeComputer(owner=self.makePerson(user=0))[0]
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
self.portal.REQUEST['test_Computer_checkState_empty_cache_notify'] = \ self.portal.REQUEST['test_Computer_checkState_empty_cache_notify'] = \
...@@ -1811,16 +1774,8 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1811,16 +1774,8 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
class TestSupportRequestTrySendNotificationMessage(SlapOSTestCaseMixin): class TestSupportRequestTrySendNotificationMessage(SlapOSTestCaseMixin):
def _makeComputer(self):
SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson(user=0)
)
return self.computer
def test_SupportRequest_trySendNotificationMessage(self): def test_SupportRequest_trySendNotificationMessage(self):
self._makeComputer() self._makeComputer(owner=self.makePerson(user=0))
person = self.computer.getSourceAdministrationValue() person = self.computer.getSourceAdministrationValue()
title = "Test Support Request %s" % self.computer.getReference() title = "Test Support Request %s" % self.computer.getReference()
text_content='Test NM content<br/>%s<br/>' % self.computer.getReference() text_content='Test NM content<br/>%s<br/>' % self.computer.getReference()
...@@ -1908,14 +1863,6 @@ class TestSupportRequestTrySendNotificationMessage(SlapOSTestCaseMixin): ...@@ -1908,14 +1863,6 @@ class TestSupportRequestTrySendNotificationMessage(SlapOSTestCaseMixin):
class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin): class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
def _makeComputer(self):
SlapOSTestCaseMixin._makeComputer(self)
# Clone computer document
self.computer.edit(
source_administration_value=self.makePerson(user=0)
)
return self.computer
def _makeHostingSubscription(self): def _makeHostingSubscription(self):
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
...@@ -1979,7 +1926,8 @@ class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin): ...@@ -1979,7 +1926,8 @@ class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
self.assertEqual(None, self.assertEqual(None,
support_request.SupportRequest_updateMonitoringDestroyRequestedState()) support_request.SupportRequest_updateMonitoringDestroyRequestedState())
support_request.setAggregateValue(self._makeComputer()) support_request.setAggregateValue(
self._makeComputer(owner=self.makePerson(user=0))[0])
self.assertEqual(None, self.assertEqual(None,
support_request.SupportRequest_updateMonitoringDestroyRequestedState()) support_request.SupportRequest_updateMonitoringDestroyRequestedState())
......
...@@ -100,11 +100,13 @@ ...@@ -100,11 +100,13 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -117,7 +119,9 @@ ...@@ -117,7 +119,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
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