Commit e0110082 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: ComputeNode_checkAndUpdateAllocationScope was dropped

parent fb5ed64f
......@@ -23,7 +23,7 @@
import transaction
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin,SlapOSTestCaseMixinWithAbort, simulate
SlapOSTestCaseMixin,SlapOSTestCaseMixinWithAbort
from DateTime import DateTime
from App.Common import rfc1123_date
......@@ -455,166 +455,6 @@ class TestSlapOSComputeNode_getTicketRelatedList(TestCRMSkinsMixin):
self.assertEqual(len(open_related_ticket_list), 0)
class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
def afterSetUp(self):
TestCRMSkinsMixin.afterSetUp(self)
self.project = self.addProject()
self._cancelTestSupportRequestList(title="%%TESTCOMPT-%")
def _getGeneratedSupportRequest(self, compute_node):
request_title = '%%We have changed allocation scope for %s' % \
compute_node.getReference()
support_request = self.portal.portal_catalog.getResultValue(
portal_type = 'Support Request',
title = request_title,
simulation_state = 'suspended',
default_aggregate_uid = compute_node.getUid()
)
return support_request
def _makeNotificationMessage(self, reference):
notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message",
title='We have changed allocation scope for %s' % reference,
text_content='Test NM content<br/>%s<br/>' % reference,
content_type='text/html',
)
return notification_message.getRelativeUrl()
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-crm-compute_node_allocation_scope.notification"\n' \
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNodeNotAllowedAllocationScope_OpenPublic"])')
def test_ComputeNodeNotAllowedAllocationScope_OpenPublic(self):
compute_node = self._makeComputeNode(self.project)[0]#, owner=self.makePerson(self.project, user=0))[0]
person = compute_node.getSourceAdministrationValue()
self.portal.REQUEST['test_ComputeNodeNotAllowedAllocationScope_OpenPublic'] = \
self._makeNotificationMessage(compute_node.getReference())
compute_node.edit(allocation_scope='open/public')
ticket = compute_node.ComputeNode_checkAndUpdateAllocationScope()
self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/personal')
#ticket = self._getGeneratedSupportRequest(compute_node)
self.assertNotEqual(None, ticket)
self.assertEqual(ticket.getSimulationState(), 'suspended')
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertEqual(event.getTitle(),
'Allocation scope of %s changed to %s' % (compute_node.getReference(), 'open/personal'))
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getSource(), person.getRelativeUrl())
self.assertEqual(event.getDestination(), ticket.getSourceSection())
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-crm-compute_node_allocation_scope.notification"\n' \
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNodeNotAllowedAllocationScope_OpenFriend"])')
def test_ComputeNodeNotAllowedAllocationScope_OpenFriend(self):
compute_node = self._makeComputeNode(self.project)[0]#, owner=self.makePerson(self.project, user=0))[0]
person = compute_node.getSourceAdministrationValue()
self.portal.REQUEST['test_ComputeNodeNotAllowedAllocationScope_OpenFriend'] = \
self._makeNotificationMessage(compute_node.getReference())
friend_person = self.makePerson(self.project)
compute_node.edit(allocation_scope='open/friend',
destination_section=friend_person.getRelativeUrl())
ticket = compute_node.ComputeNode_checkAndUpdateAllocationScope()
self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/personal')
self.assertEqual(ticket.getSimulationState(), 'suspended')
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertEqual(event.getTitle(),
'Allocation scope of %s changed to %s' % (compute_node.getReference(), 'open/personal'))
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getSource(), person.getRelativeUrl())
self.assertEqual(event.getDestination(), ticket.getSourceSection())
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
@simulate('ComputeNode_hasContactedRecently', '*args, **kwargs','return False')
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-crm-compute-node-allocation-scope-closed.notification"\n' \
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNodeToCloseAllocationScope_OpenPersonal"])')
def test_ComputeNodeToCloseAllocationScope_OpenPersonal(self):
compute_node = self._makeComputeNode(self.project)[0]#, owner=self.makePerson(self.project, user=0))[0]
person = compute_node.getSourceAdministrationValue()
target_allocation_scope = 'close/outdated'
self.portal.REQUEST['test_ComputeNodeToCloseAllocationScope_OpenPersonal'] = \
self._makeNotificationMessage(compute_node.getReference())
compute_node.edit(allocation_scope='open/personal')
support_request = compute_node.ComputeNode_checkAndUpdatePersonalAllocationScope()
self.tic()
self.assertEqual('suspended', support_request.getSimulationState())
self.assertEqual(compute_node.getAllocationScope(), target_allocation_scope)
event_list = support_request.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertEqual(event.getTitle(),
'Allocation scope of %s changed to %s' % \
(compute_node.getReference(), target_allocation_scope))
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getSource(), person.getRelativeUrl())
self.assertEqual(event.getDestination(), support_request.getSourceSection())
def test_ComputeNodeNormalAllocationScope_OpenPersonal(self):
compute_node = self._makeComputeNode(self.project)[0]#, owner=self.makePerson(self.project, user=0))[0]
person = compute_node.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider')
compute_node.edit(allocation_scope='open/personal')
compute_node.ComputeNode_checkAndUpdateAllocationScope()
self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/personal')
def test_ComputeNodeAllowedAllocationScope_OpenPublic(self):
compute_node = self._makeComputeNode(self.project)[0]#, owner=self.makePerson(self.project, user=0))[0]
person = compute_node.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider')
compute_node.edit(allocation_scope='open/public')
compute_node.ComputeNode_checkAndUpdateAllocationScope()
self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/public')
def test_ComputeNodeAllowedAllocationScope_OpenFriend(self):
compute_node = self._makeComputeNode(self.project)[0]#, owner=self.makePerson(self.project, user=0))[0]
friend_person = self.makePerson(self.project)
person = compute_node.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider')
compute_node.edit(allocation_scope='open/friend',
destination_section=friend_person.getRelativeUrl())
compute_node.ComputeNode_checkAndUpdateAllocationScope()
self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/friend')
class TestComputeNode_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
def test_ComputeNode_hasContactedRecently_newly_created(self):
......
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