Commit a3e33f96 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: fixup RegularisationRequest_checkToSendUniqEvent tests

parent b9dbb9a6
......@@ -28,9 +28,13 @@ from zExceptions import Unauthorized
from DateTime import DateTime
class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
expected_slapos_organisation = self.portal.organisation_module.newContent(
default_email_coordinate_text="foo@example.org"
)
self.expected_slapos_organisation = expected_slapos_organisation.getRelativeUrl()
def createRegularisationRequest(self):
new_id = self.generateNewId()
......@@ -41,7 +45,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
resource='foo/bar',
)
def test_checkToSendUniqEvent_no_event(self):
def test_checkToSendUniqEvent_noEvent(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
......@@ -69,8 +73,56 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
self.assertEqual(event.getSource(), self.expected_slapos_organisation)
self.assertEqual(event.getDestination(), person.getRelativeUrl())
self.assertEqual(event.getTextContent(), 'foo content')
self.assertEqual(event.getContentType(), 'text/plain')
def test_checkToSendUniqEvent_notificationMessage(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
ticket.edit(
source=self.expected_slapos_organisation,
destination_value=person,
source_project_value=person)
ticket.validate()
ticket.suspend()
before_date = DateTime()
notification_message_reference = 'test_checkToSendUniqEvent_notificationMessage%s' % self.generateNewId()
notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message",
reference=notification_message_reference,
title='notification title ${foo}',
text_content_substitution_mapping_method_id='NotificationMessage_getSubstitutionMappingDictFromEvent',
text_content='notification content ${foo}',
content_type='text/html',
)
notification_message.validate()
self.tic()
def test_checkToSendUniqEvent_service_required(self):
event = ticket.RegularisationRequest_checkToSendUniqEvent(
'service_module/slapos_crm_spam', 'foo title', 'foo content',
'foo comment',
notification_message=notification_message_reference,
substitution_method_parameter_dict={'foo': 'bar'}
)
after_date = DateTime()
self.assertEqual(ticket.getSimulationState(), 'suspended')
self.assertEqual(ticket.getResource(), 'service_module/slapos_crm_spam')
self.assertEqual(event.getPortalType(), 'Mail Message')
self.assertEqual(event.getSimulationState(), 'delivered')
self.assertTrue(event.getStartDate() >= before_date)
self.assertTrue(event.getStopDate() <= after_date)
self.assertEqual(event.getTitle(), "notification title bar")
self.assertEqual(event.getResource(), 'service_module/slapos_crm_spam')
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSource(), self.expected_slapos_organisation)
self.assertEqual(event.getDestination(), person.getRelativeUrl())
self.assertEqual(event.getTextContent(), 'notification content bar')
self.assertEqual(event.getContentType(), 'text/html')
def test_checkToSendUniqEvent_serviceRequired(self):
ticket = self.createRegularisationRequest()
self.assertRaises(
AssertionError,
......@@ -78,7 +130,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
ticket.getRelativeUrl(), '', '', ''
)
def test_checkToSendUniqEvent_call_twice_with_tic(self):
def test_checkToSendUniqEvent_callTwiceWithTic(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
......@@ -98,7 +150,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
self.assertEqual(event.getTextContent(), 'foo content')
self.assertEqual(event.getRelativeUrl(), event2.getRelativeUrl())
def test_checkToSendUniqEvent_manual_event(self):
def test_checkToSendUniqEvent_manualEvent(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
......@@ -124,7 +176,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
self.assertEqual(event.getSimulationState(), 'draft')
self.assertEqual(event.getRelativeUrl(), event2.getRelativeUrl())
def test_checkToSendUniqEvent_not_suspended(self):
def test_checkToSendUniqEvent_notSuspended(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
......@@ -138,7 +190,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
'service_module/slapos_crm_spam', 'foo2 title', 'foo2 content', 'foo2 comment')
self.assertEqual(event, None)
def test_checkToSendUniqEvent_event_not_reindexed(self):
def test_checkToSendUniqEvent_eventNotReindexed(self):
project = self.addProject()
person = self.makePerson(project, index=0, user=0)
ticket = self.createRegularisationRequest()
......@@ -156,7 +208,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
self.assertNotEqual(event, event2)
self.assertEqual(event2, None)
def test_checkToSendUniqEvent_REQUEST_disallowed(self):
def test_checkToSendUniqEvent_REQUESTdisallowed(self):
ticket = self.createRegularisationRequest()
self.assertRaises(
Unauthorized,
......@@ -164,6 +216,7 @@ class TestSlapOSRegularisationRequest_checkToSendUniqEvent(SlapOSTestCaseMixin):
'', '', '', '',
REQUEST={})
class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
SlapOSTestCaseMixinWithAbort):
......
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