Commit e6609b6f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Add tests for constraints

parent ce1a954c
...@@ -1505,6 +1505,94 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1505,6 +1505,94 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
None, None,
instance_tree.InstanceTree_checkSoftwareInstanceState()) instance_tree.InstanceTree_checkSoftwareInstanceState())
class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
self.ticket_trade_condition = portal.sale_trade_condition_module.slapos_ticket_trade_condition
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
self.support_request = portal.support_request_module.newContent(
portal_type="Support Request",
destination_decision=person_user.getRelativeUrl(),
specialise=self.ticket_trade_condition.getRelativeUrl()
)
# Value set by the init
self.assertTrue(self.support_request.getReference().startswith("SR-"),
"Reference don't start with SR- : %s" % self.support_request.getReference())
def beforeTearDown(self):
transaction.abort()
def testCheckCausalitySourceDestinationConsistency(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.support_request.approveRegistration()
self.tic()
self.logout()
self.login()
event = self.support_request.getCausalityValue()
self.assertNotEqual(event, None)
self.assertFalse(event.checkConsistency())
self.assertFalse(self.support_request.checkConsistency())
source = event.getDestination()
event.setDestination(person.getRelativeUrl())
non_consistency_list = [str(i.getTranslatedMessage()) for i in self.support_request.checkConsistency()]
self.assertEqual(non_consistency_list,
['Destination of the related event should be the slapos organisation'])
event.setSource(source)
non_consistency_list = [str(i.getTranslatedMessage()) for i in self.support_request.checkConsistency()]
self.assertEqual(non_consistency_list,
['Sender of the related event should be the customer',
'Destination of the related event should be the slapos organisation'])
def testCheckCustomerAsSourceOrDestinationConsistency(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.support_request.approveRegistration()
self.tic()
self.logout()
self.login()
event = self.support_request.getCausalityValue()
self.assertNotEqual(event, None)
self.assertFalse(event.checkConsistency())
self.assertFalse(self.support_request.checkConsistency())
person_user = self.makePerson()
self.tic()
event.setSource(person_user.getRelativeUrl())
non_consistency_list = [str(i.getTranslatedMessage()) for i in event.checkConsistency()]
self.assertEqual(non_consistency_list, [
'Customer should be source or destination of the event'
])
event.setDestination(person.getRelativeUrl())
self.assertFalse(event.checkConsistency())
class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin): class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
def _makeInstanceTree(self): def _makeInstanceTree(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