Commit 22a00a3e authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Make test independent of the Notification Messages

  Mock NotificationTool_getDocumentValue to ensure the None as return value, in order to not find eventual valid notification messages with random content from other tests or dev environment.

  No need to assert entire message, it is enought to assert message isn't empty and assert a subset of it.
parent fe79c2ea
...@@ -30,6 +30,10 @@ import difflib ...@@ -30,6 +30,10 @@ import difflib
class TestSlapOSPerson_checkToCreateRegularisationRequest(SlapOSTestCaseMixinWithAbort): class TestSlapOSPerson_checkToCreateRegularisationRequest(SlapOSTestCaseMixinWithAbort):
@simulate('NotificationTool_getDocumentValue',
'reference=None, language="en"',
'assert reference == "slapos-crm.create.regularisation.request"\n' \
'return')
@simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "1"') @simulate('Entity_statOutstandingAmount', '*args, **kwargs', 'return "1"')
def test_addRegularisationRequest_payment_requested(self): def test_addRegularisationRequest_payment_requested(self):
for preference in \ for preference in \
...@@ -637,6 +641,10 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep( ...@@ -637,6 +641,10 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
0, ticket.getRelativeUrl(), '', '', '', '' 0, ticket.getRelativeUrl(), '', '', '', ''
) )
@simulate('NotificationTool_getDocumentValue',
'reference=None, language="en"',
'assert reference == "slapos-crm.acknowledgment.escalation", reference\n' \
'return')
@simulate('RegularisationRequest_checkToSendUniqEvent', @simulate('RegularisationRequest_checkToSendUniqEvent',
'service_relative_url, title, text_content, comment, REQUEST=None', 'service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
...@@ -822,6 +830,10 @@ class TestSlapOSRegularisationRequest_triggerAcknowledgmentEscalation( ...@@ -822,6 +830,10 @@ class TestSlapOSRegularisationRequest_triggerAcknowledgmentEscalation(
ticket.RegularisationRequest_triggerAcknowledgmentEscalation, ticket.RegularisationRequest_triggerAcknowledgmentEscalation,
REQUEST={}) REQUEST={})
@simulate('NotificationTool_getDocumentValue',
'reference=None, language="en"',
'assert reference == "slapos-crm.acknowledgment.escalation", reference\n' \
'return')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
...@@ -894,6 +906,10 @@ class TestSlapOSRegularisationRequest_triggerStopReminderEscalation( ...@@ -894,6 +906,10 @@ class TestSlapOSRegularisationRequest_triggerStopReminderEscalation(
ticket.RegularisationRequest_triggerStopReminderEscalation, ticket.RegularisationRequest_triggerStopReminderEscalation,
REQUEST={}) REQUEST={})
@simulate('NotificationTool_getDocumentValue',
'reference=None, language="en"',
'assert reference == "slapos-crm.stop.reminder.escalation", reference\n' \
'return')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
...@@ -966,6 +982,10 @@ class TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation( ...@@ -966,6 +982,10 @@ class TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation(
ticket.RegularisationRequest_triggerStopAcknowledgmentEscalation, ticket.RegularisationRequest_triggerStopAcknowledgmentEscalation,
REQUEST={}) REQUEST={})
@simulate('NotificationTool_getDocumentValue',
'reference=None, language="en"',
'assert reference == "slapos-crm.stop.acknowledgment.escalation", reference\n' \
'return')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
...@@ -1038,6 +1058,10 @@ class TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation( ...@@ -1038,6 +1058,10 @@ class TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation(
ticket.RegularisationRequest_triggerDeleteReminderEscalation, ticket.RegularisationRequest_triggerDeleteReminderEscalation,
REQUEST={}) REQUEST={})
@simulate('NotificationTool_getDocumentValue',
'reference=None, language="en"',
'assert reference == "slapos-crm.delete.reminder.escalation", reference\n' \
'return')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
......
...@@ -1916,8 +1916,8 @@ class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin): ...@@ -1916,8 +1916,8 @@ class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
@simulate('ERP5Site_isSupportRequestCreationClosed', '','return 0') @simulate('ERP5Site_isSupportRequestCreationClosed', '','return 0')
@simulate('SupportRequest_trySendNotificationMessage', @simulate('SupportRequest_trySendNotificationMessage',
"message_title, message, source_relative_url", "message_title, message, source_relative_url",
'return "Visited by SupportRequest_trySendNotificationMessage '\ """assert "destroyed" in message
'%s %s %s" % (message_title, message, source_relative_url)') return "Visited by SupportRequest_trySendNotificationMessage %s %s" % (message_title, source_relative_url)""")
def testSupportRequest_updateMonitoringDestroyRequestedState(self): def testSupportRequest_updateMonitoringDestroyRequestedState(self):
support_request = self._makeSupportRequest() support_request = self._makeSupportRequest()
self.assertEqual(None, self.assertEqual(None,
...@@ -1938,8 +1938,7 @@ class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin): ...@@ -1938,8 +1938,7 @@ class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
self.commit() self.commit()
support_request.setDestinationDecisionValue(self.makePerson(user=0)) support_request.setDestinationDecisionValue(self.makePerson(user=0))
expected_text = """Visited by SupportRequest_trySendNotificationMessage Hosting Subscription was destroyed was destroyed by the user Closing this ticket as the Hosting Subscription was destroyed by the user. expected_text = """Visited by SupportRequest_trySendNotificationMessage Hosting Subscription was destroyed was destroyed by the user %s""" % support_request.getDestinationDecision()
%s""" % support_request.getDestinationDecision()
self.assertEqual(expected_text, self.assertEqual(expected_text,
support_request.SupportRequest_updateMonitoringDestroyRequestedState()) support_request.SupportRequest_updateMonitoringDestroyRequestedState())
......
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