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