Commit b9dbb9a6 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: test RegularisationRequest_deleteInstanceTreeList

parent ee0b13b6
......@@ -8,12 +8,12 @@ person = ticket.getDestinationDecisionValue(portal_type="Person")
if (state == 'suspended') and \
(person is not None) and \
(ticket.getResource() == 'service_module/slapos_crm_delete_acknowledgement'):
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Instance Tree",
validation_state=["validated"],
default_destination_section_uid=person.getUid(),
destination_section__uid=person.getUid(),
method_id='InstanceTree_deleteFromRegularisationRequest',
method_args=(person.getRelativeUrl(),),
activate_kw={'tag': tag}
......
......@@ -1033,6 +1033,7 @@ class TestSlapOSCrmDeleteInstanceTree(SlapOSTestCaseMixinWithAbort):
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
#################################################################
......@@ -1059,7 +1060,6 @@ class TestSlapOSCrmDeleteInstanceTree(SlapOSTestCaseMixinWithAbort):
slapos_crm_delete_instance_tree
self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_deleteInstanceTreeList")
def test_RegularisationRequest_deleteInstanceTreeList_alarm_otherResource(self):
ticket = self.createRegularisationRequest()
ticket.edit(resource='service_module/slapos_crm_delete_reminder')
......@@ -1071,6 +1071,150 @@ class TestSlapOSCrmDeleteInstanceTree(SlapOSTestCaseMixinWithAbort):
slapos_crm_delete_instance_tree
self._test_alarm_not_visited(alarm, ticket, "RegularisationRequest_deleteInstanceTreeList")
def createInstanceTree(self):
new_id = self.generateNewId()
instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.edit(
reference="TESTHS-%s" % new_id,
)
instance_tree.validate()
self.portal.portal_workflow._jumpToStateFor(
instance_tree, 'start_requested')
return instance_tree
def test_RegularisationRequest_deleteInstanceTreeList_script_REQUESTdisallowed(self):
ticket = self.createRegularisationRequest()
self.assertRaises(
Unauthorized,
ticket.RegularisationRequest_deleteInstanceTreeList,
'footag',
REQUEST={})
@simulate('InstanceTree_deleteFromRegularisationRequest',
'person, REQUEST=None',
'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \
'comment="Visited by InstanceTree_deleteFromRegularisationRequest ' \
'%s" % (person))')
def test_RegularisationRequest_deleteInstanceTreeList_script_matchingSubscription(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
instance_tree = self.createInstanceTree()
ticket.edit(
destination_decision_value=person,
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
ticket.suspend()
instance_tree.edit(
destination_section=person.getRelativeUrl(),
)
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertTrue(result)
self.tic()
self.assertEqual(
'Visited by InstanceTree_deleteFromRegularisationRequest ' \
'%s' % person.getRelativeUrl(),
instance_tree.workflow_history['edit_workflow'][-1]['comment'])
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_RegularisationRequest_deleteInstanceTreeList_script_otherSubscription(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
ticket.edit(
destination_decision_value=person,
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
ticket.suspend()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertTrue(result)
self.tic()
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_RegularisationRequest_deleteInstanceTreeList_script_noPerson(self):
ticket = self.createRegularisationRequest()
ticket.edit(
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
ticket.suspend()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertFalse(result)
self.tic()
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_RegularisationRequest_deleteInstanceTreeList_script_notSuspended(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
ticket.edit(
destination_decision_value=person,
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertFalse(result)
self.tic()
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_RegularisationRequest_deleteInstanceTreeList_script_otherResource(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
ticket.edit(
destination_decision_value=person,
resource='service_module/slapos_crm_delete_reminder',
)
ticket.validate()
ticket.suspend()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertFalse(result)
self.tic()
class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort):
......
......@@ -541,158 +541,3 @@ class TestSlapOSInstanceTree_deleteFromRegularisationRequest(
instance_tree.InstanceTree_deleteFromRegularisationRequest,
'foobar')
class TestSlapOSRegularisationRequest_deleteInstanceTreeList(
SlapOSTestCaseMixinWithAbort):
def createRegularisationRequest(self):
new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
title="Test Reg. Req.%s" % new_id,
reference="TESTREGREQ-%s" % new_id,
resource='foo/bar',
)
def createInstanceTree(self):
new_id = self.generateNewId()
instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.edit(
reference="TESTHS-%s" % new_id,
)
instance_tree.validate()
self.portal.portal_workflow._jumpToStateFor(
instance_tree, 'start_requested')
return instance_tree
def test_deleteInstanceTreeList_REQUEST_disallowed(self):
ticket = self.createRegularisationRequest()
self.assertRaises(
Unauthorized,
ticket.RegularisationRequest_deleteInstanceTreeList,
'footag',
REQUEST={})
@simulate('InstanceTree_deleteFromRegularisationRequest',
'person, REQUEST=None',
'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \
'comment="Visited by InstanceTree_deleteFromRegularisationRequest ' \
'%s" % (person))')
def test_deleteInstanceTreeList_matching_subscription(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
instance_tree = self.createInstanceTree()
ticket.edit(
source_project_value=person,
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
ticket.suspend()
instance_tree.edit(
destination_section=person.getRelativeUrl(),
)
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertTrue(result)
self.tic()
self.assertEqual(
'Visited by InstanceTree_deleteFromRegularisationRequest ' \
'%s' % person.getRelativeUrl(),
instance_tree.workflow_history['edit_workflow'][-1]['comment'])
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_deleteInstanceTreeList_other_subscription(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
ticket.edit(
source_project_value=person,
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
ticket.suspend()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertTrue(result)
self.tic()
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_deleteInstanceTreeList_no_person(self):
ticket = self.createRegularisationRequest()
ticket.edit(
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
ticket.suspend()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertFalse(result)
self.tic()
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_deleteInstanceTreeList_not_suspended(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
ticket.edit(
source_project_value=person,
resource='service_module/slapos_crm_delete_acknowledgement',
)
ticket.validate()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertFalse(result)
self.tic()
@simulate('InstanceTree_deleteFromRegularisationRequest',
'*args, **kwargs',
'raise NotImplementedError, "Should not have been called"')
def test_deleteInstanceTreeList_other_resource(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
self.createInstanceTree()
ticket.edit(
source_project_value=person,
resource='service_module/slapos_crm_delete_reminder',
)
ticket.validate()
ticket.suspend()
self.tic()
result = ticket.\
RegularisationRequest_deleteInstanceTreeList('footag')
self.assertFalse(result)
self.tic()
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