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
95a48d72
Commit
95a48d72
authored
Sep 21, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: test SupportRequest_updateMonitoringState
parent
8e6d8d06
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
184 deletions
+115
-184
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_updateMonitoringDestroyRequestedState.py
...g/SupportRequest_updateMonitoringDestroyRequestedState.py
+0
-33
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_updateMonitoringDestroyRequestedState.xml
.../SupportRequest_updateMonitoringDestroyRequestedState.xml
+0
-62
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_updateMonitoringState.py
...os_crm_monitoring/SupportRequest_updateMonitoringState.py
+26
-2
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+89
-0
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
+0
-87
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_updateMonitoringDestroyRequestedState.py
deleted
100644 → 0
View file @
8e6d8d06
""" Close Support Request which are related to a Destroy Requested Instance. """
portal
=
context
.
getPortalObject
()
if
context
.
getSimulationState
()
==
"invalidated"
:
return
document
=
context
.
getAggregateValue
()
if
document
is
not
None
and
document
.
getSlapState
()
==
"destroy_requested"
:
person
=
context
.
getDestinationDecision
(
portal_type
=
"Person"
)
if
not
person
:
return
# Send Notification message
message
=
""" Closing this ticket as the Instance Tree was destroyed by the user.
"""
notification_message
=
portal
.
portal_notifications
.
getDocumentValue
(
reference
=
"slapos-crm-support-request-close-destroyed-notification"
)
if
notification_message
is
not
None
:
mapping_dict
=
{
'instance_tree_title'
:
document
.
getTitle
()}
message
=
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
mapping_dict
})
ticket_title
=
"Instance Tree was destroyed was destroyed by the user"
event
=
context
.
SupportRequest_getLastEvent
(
ticket_title
)
if
event
is
None
:
context
.
notify
(
message_title
=
ticket_title
,
message
=
message
)
context
.
invalidate
()
return
context
.
REQUEST
.
get
(
"ticket_notified_item"
)
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_updateMonitoringDestroyRequestedState.xml
deleted
100644 → 0
View file @
8e6d8d06
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SupportRequest_updateMonitoringDestroyRequestedState
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_updateMonitoringState.py
View file @
95a48d72
""" Close Support Request which are related to a Destroy Requested Instance. """
portal
=
context
.
getPortalObject
()
if
context
.
getSimulationState
()
==
"invalidated"
:
return
document
=
context
.
get
Aggregate
Value
(
portal_type
=
"Instance Tree"
)
document
=
context
.
get
Causality
Value
(
portal_type
=
"Instance Tree"
)
if
document
is
None
:
return
if
document
.
getSlapState
()
==
"destroy_requested"
:
return
context
.
SupportRequest_updateMonitoringDestroyRequestedState
()
# Send Notification message
message
=
""" Closing this ticket as the Instance Tree was destroyed by the user.
"""
ticket_title
=
"Instance Tree was destroyed was destroyed by the user"
event
=
context
.
SupportRequest_getLastEvent
(
ticket_title
)
if
event
is
None
:
context
.
Ticket_createProjectEvent
(
ticket_title
,
'outgoing'
,
'Web Message'
,
portal
.
service_module
.
slapos_crm_information
.
getRelativeUrl
(),
text_content
=
message
,
content_type
=
'text/plain'
,
notification_message
=
"slapos-crm-support-request-close-destroyed-notification"
,
#language=XXX,
substitution_method_parameter_dict
=
{
'instance_tree_title'
:
document
.
getTitle
()
}
)
context
.
invalidate
()
return
event
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
95a48d72
...
...
@@ -1304,6 +1304,95 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort):
slapos_crm_update_support_request_state
self
.
_test_alarm_not_visited
(
alarm
,
support_request
,
"SupportRequest_updateMonitoringState"
)
def
_makeNotificationMessage
(
self
,
reference
):
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Closing Support Request %s'
%
reference
,
text_content
=
'Test NM content<br/>%s<br/>'
%
reference
,
content_type
=
'text/html'
,
)
return
notification_message
.
getRelativeUrl
()
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 0'
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None, **kw'
,
'assert reference == "slapos-crm-support-request-close-destroyed-notification", reference
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["test_SupportRequest_updateMonitoringState_notify"])'
)
def
test_SupportRequest_updateMonitoringState_script_notifyClose
(
self
):
support_request
=
self
.
_makeSupportRequest
()
support_request
.
setResource
(
"service_module/slapos_crm_monitoring"
)
instance_tree
=
self
.
_makeInstanceTree
()
support_request
.
setCausalityValue
(
instance_tree
)
self
.
tic
()
self
.
portal
.
REQUEST
[
'test_SupportRequest_updateMonitoringState_notify'
]
=
\
self
.
_makeNotificationMessage
(
instance_tree
.
getReference
())
self
.
tic
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
"destroy_requested"
)
support_request
.
SupportRequest_updateMonitoringState
()
self
.
tic
()
ticket
=
support_request
event_list
=
ticket
.
getFollowUpRelatedValueList
()
self
.
assertEqual
(
len
(
event_list
),
1
)
event
=
event_list
[
0
]
self
.
assertEqual
(
event
.
getTitle
(),
"Instance Tree was destroyed was destroyed by the user"
)
self
.
assertIn
(
instance_tree
.
getReference
(),
event
.
getTextContent
())
self
.
assertEqual
(
event
.
getFollowUp
(),
ticket
.
getRelativeUrl
())
self
.
assertEqual
(
event
.
getSourceProject
(),
instance_tree
.
getFollowUp
())
self
.
assertEqual
(
ticket
.
getSourceProject
(),
instance_tree
.
getFollowUp
())
self
.
assertEqual
(
ticket
.
getCausality
(),
instance_tree
.
getRelativeUrl
())
self
.
assertEqual
(
ticket
.
getSimulationState
(),
"invalidated"
)
self
.
assertEqual
(
event
.
getSimulationState
(),
"delivered"
)
self
.
assertEqual
(
event
.
getPortalType
(),
"Web Message"
)
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 0'
)
def
test_SupportRequest_updateMonitoringState_script_notDestroyed
(
self
):
support_request
=
self
.
_makeSupportRequest
()
support_request
.
setResource
(
"service_module/slapos_crm_monitoring"
)
instance_tree
=
self
.
_makeInstanceTree
()
support_request
.
setCausalityValue
(
instance_tree
)
self
.
tic
()
self
.
portal
.
REQUEST
[
'test_SupportRequest_updateMonitoringState_notify'
]
=
\
self
.
_makeNotificationMessage
(
instance_tree
.
getReference
())
self
.
tic
()
support_request
.
SupportRequest_updateMonitoringState
()
self
.
tic
()
ticket
=
support_request
event_list
=
ticket
.
getFollowUpRelatedValueList
()
self
.
assertEqual
(
len
(
event_list
),
0
)
self
.
assertEqual
(
ticket
.
getSimulationState
(),
"validated"
)
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 0'
)
def
test_SupportRequest_updateMonitoringState_script_invalidated
(
self
):
support_request
=
self
.
_makeSupportRequest
()
support_request
.
setResource
(
"service_module/slapos_crm_monitoring"
)
instance_tree
=
self
.
_makeInstanceTree
()
support_request
.
setCausalityValue
(
instance_tree
)
self
.
tic
()
self
.
portal
.
REQUEST
[
'test_SupportRequest_updateMonitoringState_notify'
]
=
\
self
.
_makeNotificationMessage
(
instance_tree
.
getReference
())
self
.
tic
()
support_request
.
invalidate
()
support_request
.
SupportRequest_updateMonitoringState
()
self
.
tic
()
ticket
=
support_request
event_list
=
ticket
.
getFollowUpRelatedValueList
()
self
.
assertEqual
(
len
(
event_list
),
0
)
self
.
assertEqual
(
ticket
.
getSimulationState
(),
"invalidated"
)
class
TestSlaposCrmSendPendingTicket_reminder
(
SlapOSTestCaseMixinWithAbort
):
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
View file @
95a48d72
...
...
@@ -1174,93 +1174,6 @@ class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin):
event
.
setDestination
(
person
.
getRelativeUrl
())
self
.
assertFalse
(
event
.
checkConsistency
())
class
TestSupportRequestUpdateMonitoringState
(
SlapOSTestCaseMixin
):
def
_makeInstanceTree
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
=
self
.
portal
\
.
instance_tree_module
.
template_instance_tree
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
.
validate
()
new_id
=
self
.
generateNewId
()
instance_tree
.
edit
(
title
=
"Test hosting sub ticket %s"
%
new_id
,
reference
=
"TESTHST-%s"
%
new_id
,
destination_section_value
=
person
)
return
instance_tree
def
_makeSupportRequest
(
self
):
return
self
.
portal
.
restrictedTraverse
(
self
.
portal
.
portal_preferences
.
getPreferredSupportRequestTemplate
()).
\
Base_createCloneDocument
(
batch_mode
=
1
)
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 0'
)
@
simulate
(
'SupportRequest_updateMonitoringDestroyRequestedState'
,
""
,
'return "Visited by SupportRequest_updateMonitoringDestroyRequestedState '
\
'%s" % (context.getRelativeUrl(),)'
)
def
testSupportRequest_updateMonitoringState
(
self
):
support_request
=
self
.
_makeSupportRequest
()
self
.
assertEqual
(
None
,
support_request
.
SupportRequest_updateMonitoringState
())
support_request
.
validate
()
self
.
assertEqual
(
None
,
support_request
.
SupportRequest_updateMonitoringState
())
hs
=
self
.
_makeInstanceTree
()
support_request
.
setAggregateValue
(
hs
)
hs
.
getSlapState
=
getFakeSlapState
self
.
assertEqual
(
"Visited by SupportRequest_updateMonitoringDestroyRequestedState %s"
%
\
support_request
.
getRelativeUrl
(),
support_request
.
SupportRequest_updateMonitoringState
())
support_request
.
invalidate
()
self
.
assertEqual
(
None
,
support_request
.
SupportRequest_updateMonitoringState
())
@
simulate
(
'ERP5Site_isSupportRequestCreationClosed'
,
''
,
'return 0'
)
def
testSupportRequest_updateMonitoringDestroyRequestedState
(
self
):
support_request
=
self
.
_makeSupportRequest
()
self
.
assertEqual
(
None
,
support_request
.
SupportRequest_updateMonitoringDestroyRequestedState
())
support_request
.
validate
()
self
.
assertEqual
(
None
,
support_request
.
SupportRequest_updateMonitoringDestroyRequestedState
())
support_request
.
setAggregateValue
(
self
.
_makeComputeNode
(
self
.
project
)[
0
])
#, owner=self.makePerson(user=0))[0])
support_request
.
setDestinationDecisionValue
(
self
.
makePerson
(
self
.
project
,
user
=
0
))
self
.
assertEqual
(
None
,
support_request
.
SupportRequest_updateMonitoringDestroyRequestedState
())
hs
=
self
.
_makeInstanceTree
()
support_request
.
setAggregateValue
(
hs
)
self
.
tic
()
hs
.
getSlapState
=
getFakeSlapState
self
.
commit
()
self
.
assertNotEqual
(
None
,
support_request
.
SupportRequest_updateMonitoringDestroyRequestedState
())
self
.
tic
()
event_list
=
support_request
.
getFollowUpRelatedValueList
()
self
.
assertEqual
(
len
(
event_list
),
1
)
event
=
event_list
[
0
]
self
.
assertEqual
(
event
.
getTitle
(),
'Instance Tree was destroyed was destroyed by the user'
)
self
.
assertEqual
(
event
.
getSource
(),
support_request
.
getDestinationDecision
())
self
.
assertEqual
(
event
.
getDestination
(),
support_request
.
getSourceSection
())
self
.
assertEqual
(
"invalidated"
,
support_request
.
getSimulationState
())
class
TestSlapOSFolder_getTicketFeedUrl
(
TestCRMSkinsMixin
):
...
...
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