Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos.core
Commits
370d5d6f
Commit
370d5d6f
authored
Sep 29, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: test RegularisationRequest_triggerStopAcknowledgmentEscalation
parent
bbc9f0d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
105 deletions
+50
-105
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerStopAcknowledgmentEscalation.py
...ularisationRequest_triggerStopAcknowledgmentEscalation.py
+7
-26
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+43
-3
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMRegularisationRequestSkins.py
...ents/test.erp5.testSlapOSCRMRegularisationRequestSkins.py
+0
-76
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerStopAcknowledgmentEscalation.py
View file @
370d5d6f
...
...
@@ -2,19 +2,9 @@ from zExceptions import Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
ndays
=
7
language
=
"en"
recipient
=
context
.
getDestinationSectionValue
()
if
recipient
is
not
None
:
language
=
recipient
.
getLanguage
(
"en"
)
notification_message
=
portal
.
portal_notifications
.
getDocumentValue
(
language
=
language
,
reference
=
"slapos-crm.stop.acknowledgment.escalation"
)
if
notification_message
is
None
:
subject
=
'Last reminder: invoice payment requested'
body
=
"""Dear user,
subject
=
'Last reminder: invoice payment requested'
body
=
"""Dear user,
We would like to remind you the unpaid invoice you have on %s.
If no payment is done during the coming days, we will delete all your instances.
...
...
@@ -22,20 +12,6 @@ If no payment is done during the coming days, we will delete all your instances.
Regards,
The slapos team
"""
%
context
.
getPortalObject
().
portal_preferences
.
getPreferredSlaposWebSiteUrl
()
else
:
notification_mapping_dict
=
{
'user_name'
:
context
.
getDestinationSectionTitle
(),
'days'
:
ndays
}
subject
=
notification_message
.
getTitle
()
# Preserve HTML else convert to text
if
notification_message
.
getContentType
()
==
"text/html"
:
body
=
notification_message
.
asEntireHTML
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
notification_mapping_dict
})
else
:
body
=
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
notification_mapping_dict
})
return
context
.
RegularisationRequest_checkToTriggerNextEscalationStep
(
delay_period_in_days
=
ndays
,
...
...
@@ -44,4 +20,9 @@ return context.RegularisationRequest_checkToTriggerNextEscalationStep(
title
=
subject
,
text_content
=
body
,
comment
=
'Deleting reminder.'
,
notification_message
=
"slapos-crm.stop.acknowledgment.escalation"
,
substitution_method_parameter_dict
=
{
'user_name'
:
context
.
getDestinationSectionTitle
(),
'days'
:
ndays
}
)
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
370d5d6f
...
...
@@ -633,7 +633,7 @@ class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(Sl
#################################################################
# slapos_crm_trigger_stop_acknowledgment_escalation
#################################################################
def
test_
triggerStopAcknowledgmentEscalation_matching_regularisation_r
equest
(
self
):
def
test_
RegularisationRequest_triggerStopAcknowledgmentEscalation_alarm_matchingRegularisationR
equest
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
resource
=
'service_module/slapos_crm_stop_acknowledgement'
)
ticket
.
validate
()
...
...
@@ -645,7 +645,7 @@ class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(Sl
self
.
_test_alarm
(
alarm
,
ticket
,
"RegularisationRequest_triggerStopAcknowledgmentEscalation"
)
def
test_
triggerStopAcknowledgmentEscalation_not_s
uspended
(
self
):
def
test_
RegularisationRequest_triggerStopAcknowledgmentEscalation_alarm_notS
uspended
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
resource
=
'service_module/slapos_crm_stop_acknowledgement'
)
ticket
.
validate
()
...
...
@@ -656,7 +656,7 @@ class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(Sl
self
.
_test_alarm_not_visited
(
alarm
,
ticket
,
"RegularisationRequest_triggerStopAcknowledgmentEscalation"
)
def
test_
triggerStopAcknowledgmentEscalation_not_expected_r
esource
(
self
):
def
test_
RegularisationRequest_triggerStopAcknowledgmentEscalation_alarm_notExpectedR
esource
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
validate
()
ticket
.
suspend
()
...
...
@@ -667,6 +667,46 @@ class TestSlapOSCrmTriggerEscalationOnStopAcknowledgmentRegularisationRequest(Sl
self
.
_test_alarm_not_visited
(
alarm
,
ticket
,
"RegularisationRequest_triggerStopAcknowledgmentEscalation"
)
def
test_RegularisationRequest_triggerStopAcknowledgmentEscalation_script_REQUESTdisallowed
(
self
):
ticket
=
self
.
createRegularisationRequest
()
self
.
assertRaises
(
Unauthorized
,
ticket
.
RegularisationRequest_triggerStopAcknowledgmentEscalation
,
REQUEST
=
{})
@
simulate
(
'RegularisationRequest_checkToTriggerNextEscalationStep'
,
'delay_period_in_days, current_service_relative_url, '
\
'next_service_relative_url, title, text_content, comment, '
\
'notification_message=None, substitution_method_parameter_dict=None, '
\
'REQUEST=None'
,
'context.portal_workflow.doActionFor('
\
'context, action="edit_action", '
\
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep '
\
'%s %s %s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, notification_message, substitution_method_parameter_dict))'
)
def
test_RegularisationRequest_triggerStopAcknowledgmentEscalation_script_matchingEvent
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
RegularisationRequest_triggerStopAcknowledgmentEscalation
()
self
.
assertEqual
(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep '
\
'%s %s %s %s %s %s %s %s'
%
\
(
7
,
'service_module/slapos_crm_stop_acknowledgement'
,
'service_module/slapos_crm_delete_reminder'
,
'Last reminder: invoice payment requested'
,
"""Dear user,
We would like to remind you the unpaid invoice you have on %s.
If no payment is done during the coming days, we will delete all your instances.
Regards,
The slapos team
"""
%
self
.
portal
.
portal_preferences
.
getPreferredSlaposWebSiteUrl
(),
'Deleting reminder.'
,
'slapos-crm.stop.acknowledgment.escalation'
,
"{'user_name': None, 'days': 7}"
),
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestSlapOSCrmTriggerEscalationOnDeleteReminderRegularisationRequest
(
SlapOSTestCaseMixinWithAbort
):
def
createRegularisationRequest
(
self
):
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMRegularisationRequestSkins.py
View file @
370d5d6f
...
...
@@ -364,82 +364,6 @@ class TestSlapOSRegularisationRequest_checkToTriggerNextEscalationStep(
REQUEST
=
{})
class
TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation
(
SlapOSTestCaseMixinWithAbort
):
def
test_triggerStopAcknowledgmentEscalation_REQUEST_disallowed
(
self
):
ticket
=
self
.
createRegularisationRequest
()
self
.
assertRaises
(
Unauthorized
,
ticket
.
RegularisationRequest_triggerStopAcknowledgmentEscalation
,
REQUEST
=
{})
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None, language="en"'
,
'assert reference == "slapos-crm.stop.acknowledgment.escalation", reference
\
n
'
\
'return'
)
@
simulate
(
'RegularisationRequest_checkToTriggerNextEscalationStep'
,
'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None'
,
'context.portal_workflow.doActionFor('
\
'context, action="edit_action", '
\
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep '
\
'%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))'
)
def
test_checkToTriggerNextEscalationStep_matching_event
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
RegularisationRequest_triggerStopAcknowledgmentEscalation
()
self
.
assertEqual
(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep '
\
'%s %s %s %s %s %s'
%
\
(
7
,
'service_module/slapos_crm_stop_acknowledgement'
,
'service_module/slapos_crm_delete_reminder'
,
'Last reminder: invoice payment requested'
,
"""Dear user,
We would like to remind you the unpaid invoice you have on %s.
If no payment is done during the coming days, we will delete all your instances.
Regards,
The slapos team
"""
%
self
.
portal
.
portal_preferences
.
getPreferredSlaposWebSiteUrl
(),
'Deleting reminder.'
),
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None, language="en"'
,
'assert reference == "slapos-crm.stop.acknowledgment.escalation"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])'
)
@
simulate
(
'RegularisationRequest_checkToTriggerNextEscalationStep'
,
'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None'
,
'context.portal_workflow.doActionFor('
\
'context, action="edit_action", '
\
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep '
\
'%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))'
)
def
test_checkToTriggerNextEscalationStep_notification_message
(
self
):
ticket
=
self
.
createRegularisationRequest
()
new_id
=
self
.
generateNewId
()
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
new_id
,
text_content
=
'Test NM content
\
n
%s
\
n
'
%
new_id
,
content_type
=
'text/plain'
,
)
self
.
portal
.
REQUEST
\
[
'test_checkToTriggerNextEscalationStep_notification_message'
]
=
\
notification_message
.
getRelativeUrl
()
ticket
.
RegularisationRequest_triggerStopAcknowledgmentEscalation
()
self
.
assertEqual
(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep '
\
'%s %s %s %s %s %s'
%
\
(
7
,
'service_module/slapos_crm_stop_acknowledgement'
,
'service_module/slapos_crm_delete_reminder'
,
'Test NM title %s'
%
new_id
,
'Test NM content
\
n
%s
\
n
'
%
new_id
,
'Deleting reminder.'
),
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation
(
SlapOSTestCaseMixinWithAbort
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment