Commit 8a1f02c1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Add tests for Event_checkCustomerAsSourceOrDestinationConsistency

parent bbca224a
...@@ -27,7 +27,6 @@ from erp5.component.test.SlapOSTestCaseMixin import \ ...@@ -27,7 +27,6 @@ from erp5.component.test.SlapOSTestCaseMixin import \
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
import os import os
from DateTime import DateTime
from zExceptions import Unauthorized from zExceptions import Unauthorized
...@@ -42,23 +41,6 @@ class TestCRMSkinsMixin(SlapOSTestCaseMixinWithAbort): ...@@ -42,23 +41,6 @@ class TestCRMSkinsMixin(SlapOSTestCaseMixinWithAbort):
self.person = self.makePerson(self.project, new_id=self.new_id, self.person = self.makePerson(self.project, new_id=self.new_id,
index=0, user=0) index=0, user=0)
def _cancelTestSupportRequestList(self, title="%"):
for support_request in self.portal.portal_catalog(
portal_type="Support Request",
title=title,
simulation_state=["validated", "suspended"]):
support_request.invalidate()
self.tic()
def _updatePersonAssignment(self, person, role='role/member'):
for assignment in person.contentValues(portal_type="Assignment"):
assignment.cancel()
assignment = person.newContent(portal_type='Assignment')
assignment.setRole(role)
assignment.setStartDate(DateTime())
assignment.open()
return assignment
def _makeInstanceTree(self, project): def _makeInstanceTree(self, project):
person = self.portal.person_module\ person = self.portal.person_module\
.newContent(portal_type="Person") .newContent(portal_type="Person")
...@@ -250,7 +232,6 @@ class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin): ...@@ -250,7 +232,6 @@ class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin):
portal_type="Support Request", portal_type="Support Request",
destination_value=person_user, destination_value=person_user,
destination_decision_value=person_user, destination_decision_value=person_user,
#specialise=
) )
# Value set by the init # Value set by the init
...@@ -289,8 +270,73 @@ class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin): ...@@ -289,8 +270,73 @@ class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin):
'Customer should be source or destination of the event' 'Customer should be source or destination of the event'
]) ])
# Check script in case
non_consistency_list = event.Event_checkCustomerAsSourceOrDestinationConsistency()
self.assertEqual(non_consistency_list, [
'Customer should be source or destination of the event'
])
event.setDestination(person.getRelativeUrl()) event.setDestination(person.getRelativeUrl())
self.assertFalse(event.checkConsistency()) self.assertFalse(event.checkConsistency())
# Check script in case
self.assertEqual([],
event.Event_checkCustomerAsSourceOrDestinationConsistency())
class TestProject_createSupportRequestWithCausality(TestCRMSkinsMixin):
def testProject_createSupportRequestWithCausality(self):
self._makeComputeNode(self.project)
self._makeComplexComputeNode(self.project)
new_id = self.generateNewId()
title = "TestProject_createSupportRequestWithCausality title %s" % (new_id)
text_content = "Test Description %s" % (new_id)
ticket = self.project.Project_createSupportRequestWithCausality(
title=title,
text_content=text_content,
causality=self.compute_node.getRelativeUrl(),
destination_decision=self.person.getRelativeUrl())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getSimulationState(), 'submitted')
self.assertEqual(ticket.getTitle(), title)
self.tic()
self.assertEqual(None,
self.project.Project_createSupportRequestWithCausality(
title=title,
text_content=text_content,
causality=self.compute_node.getRelativeUrl(),
destination_decision=self.person.getRelativeUrl()))
self.assertEqual(None,
self.project.Project_createSupportRequestWithCausality(
title="Some other title",
text_content="Some other content",
causality=self.compute_node.getRelativeUrl(),
destination_decision=self.person.getRelativeUrl()))
# Same tittle different causality
ticket = self.project.Project_createSupportRequestWithCausality(
title=title,
text_content=text_content,
causality=self.start_requested_software_instance.getSpecialise(),
destination_decision=self.person.getRelativeUrl())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getSimulationState(), 'submitted')
self.assertEqual(ticket.getTitle(), title)
self.tic()
self.assertEqual(None,
self.project.Project_createSupportRequestWithCausality(
title="Some other title",
text_content="Some other content",
causality=self.start_requested_software_instance.getSpecialise(),
destination_decision=self.person.getRelativeUrl()))
class TestTicket_createProjectEvent(TestCRMSkinsMixin): class TestTicket_createProjectEvent(TestCRMSkinsMixin):
......
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