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
0
Merge Requests
0
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
Léo-Paul Géneau
slapos.core
Commits
97ec74c4
Commit
97ec74c4
authored
Sep 13, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: Fixup and write tests
parent
26551a5a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
233 additions
and
5 deletions
+233
-5
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_getSlapOSPendingTicket.py
...ns/slapos_crm_monitoring/Person_getSlapOSPendingTicket.py
+4
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_getSlapOSPendingTicketMessageTemplate.py
...onitoring/Person_getSlapOSPendingTicketMessageTemplate.py
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_sendPendingTicketReminder.xml
...lapos_crm_monitoring/Person_sendPendingTicketReminder.xml
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_sendSlapOSPendingTicketNotification.py
..._monitoring/Person_sendSlapOSPendingTicketNotification.py
+1
-1
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
+226
-1
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_getSlapOSPendingTicket.py
View file @
97ec74c4
from
Products.ZSQLCatalog.SQLCatalog
import
ComplexQuery
,
SimpleQuery
portal
=
context
.
getPortalObject
()
person_uid
=
context
.
getUid
()
query
=
ComplexQuery
(
ComplexQuery
(
SimpleQuery
(
portal_type
=
[
"Support Request"
,
"Regularisation Request"
]),
SimpleQuery
(
simulation_state
=
"suspended"
),
SimpleQuery
(
destination_decision_uid
=
person_uid
),
logical_operator
=
'and'
),
ComplexQuery
(
SimpleQuery
(
portal_type
=
"Upgrade Decision
Line
"
),
SimpleQuery
(
portal_type
=
"Upgrade Decision"
),
SimpleQuery
(
simulation_state
=
"confirmed"
),
SimpleQuery
(
destination_decision_uid
=
person_uid
),
logical_operator
=
'and'
),
logical_operator
=
'or'
)
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_getSlapOSPendingTicketMessageTemplate.py
View file @
97ec74c4
...
...
@@ -12,6 +12,6 @@ if notification_message is not None:
return
notification_message
.
getTitle
(),
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
mapping_dict
})
message
=
""" You have %s pending tickets """
%
pending_ticket_list_amount
,
message
=
""" You have %s pending tickets """
%
pending_ticket_list_amount
return
message
,
message
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_sendPendingTicketReminder.xml
View file @
97ec74c4
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
response_event_title, response_event_text_content, batch_mode=False, **kw
</string>
</value>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Person_sendSlapOSPendingTicketNotification.py
View file @
97ec74c4
...
...
@@ -18,7 +18,7 @@ event_kw = {
# Create event
event
=
portal
.
event_module
.
newContent
(
**
event_kw
)
event
.
plan
()
event
.
s
ent
(
comment
=
"Sent via Person_sendSlapOSPendingTicketNotification"
)
event
.
s
tart
(
send_mail
=
True
,
comment
=
"Sent via Person_sendSlapOSPendingTicketNotification"
)
if
batch_mode
:
return
event
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
View file @
97ec74c4
...
...
@@ -1400,7 +1400,6 @@ class TestSupportRequestUpdateMonitoringState(SlapOSTestCaseMixin):
support_request
.
getSimulationState
())
class
TestSlapOSFolder_getTicketFeedUrl
(
TestCRMSkinsMixin
):
def
_test
(
self
,
module
):
...
...
@@ -1425,3 +1424,229 @@ class TestSlapOSFolder_getTicketFeedUrl(TestCRMSkinsMixin):
def
test_Folder_getTicketFeedUrl_incident_response_module
(
self
):
self
.
_test
(
self
.
portal
.
incident_response_module
)
class
TestSlapOSPerson_getSlapOSPendingTicket
(
TestCRMSkinsMixin
):
def
test_getSlapOSPendingTicket_support_request
(
self
):
person
=
self
.
makePerson
()
ticket
=
self
.
portal
.
support_request_module
.
newContent
(
\
title
=
"Test Support Request %s"
%
self
.
new_id
,
destination_decision
=
person
.
getRelativeUrl
())
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
# Not indexed yet
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
self
.
tic
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
submit
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
validate
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
suspend
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
1
)
self
.
assertEqual
(
pending_ticket_list
[
0
].
getUid
(),
ticket
.
getUid
())
ticket
.
invalidate
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
def
test_getSlapOSPendingTicket_support_request_cancelled
(
self
):
person
=
self
.
makePerson
()
ticket
=
self
.
portal
.
support_request_module
.
newContent
(
\
title
=
"Test Support Request %s"
%
self
.
new_id
,
destination_decision
=
person
.
getRelativeUrl
())
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
# Not indexed yet
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
self
.
tic
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
submit
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
cancel
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
def
test_getSlapOSPendingTicket_upgrade_decision
(
self
):
def
newUpgradeDecision
():
ticket
=
self
.
portal
.
upgrade_decision_module
.
newContent
(
portal_type
=
'Upgrade Decision'
,
title
=
"Upgrade Decision Test %s"
%
self
.
new_id
,
reference
=
"TESTUD-%s"
%
self
.
new_id
)
ticket
.
immediateReindexObject
()
return
ticket
person
=
self
.
makePerson
()
ticket
=
newUpgradeDecision
()
ticket
.
setDestinationDecisionValue
(
person
)
ticket
.
newContent
(
portal_type
=
"Upgrade Decision Line"
)
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
# Not indexed yet
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
self
.
tic
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
plan
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
confirm
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
1
)
self
.
assertEqual
(
pending_ticket_list
[
0
].
getUid
(),
ticket
.
getUid
())
ticket
.
start
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
stop
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
deliver
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
def
test_getSlapOSPendingTicket_upgrade_decision_cancel
(
self
):
def
newUpgradeDecision
():
ticket
=
self
.
portal
.
upgrade_decision_module
.
newContent
(
portal_type
=
'Upgrade Decision'
,
title
=
"Upgrade Decision Test %s"
%
self
.
new_id
,
reference
=
"TESTUD-%s"
%
self
.
new_id
)
ticket
.
immediateReindexObject
()
return
ticket
person
=
self
.
makePerson
()
ticket
=
newUpgradeDecision
()
ticket
.
setDestinationDecisionValue
(
person
)
ticket
.
newContent
(
portal_type
=
"Upgrade Decision Line"
)
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
# Not indexed yet
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
self
.
tic
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
plan
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
ticket
.
cancel
()
ticket
.
immediateReindexObject
()
pending_ticket_list
=
person
.
Person_getSlapOSPendingTicket
()
self
.
assertEqual
(
len
(
pending_ticket_list
),
0
)
class
TestSlapOSPerson_getSlapOSPendingTicketMessageTemplate
(
TestCRMSkinsMixin
):
@
simulate
(
'Person_getSlapOSPendingTicket'
,
'*args, **kwargs'
,
'return range(99)'
)
def
test_getSlapOSPendingTicketMessageTemplate
(
self
):
person
=
self
.
makePerson
()
title
,
message
=
person
.
Person_getSlapOSPendingTicketMessageTemplate
()
self
.
assertEqual
(
""" You have 99 pending tickets """
,
title
)
self
.
assertEqual
(
""" You have 99 pending tickets """
,
message
)
def
_makeNotificationMessage
(
self
):
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Pending ticket'
,
text_content_substitution_mapping_method_id
=
'NotificationMessage_getSubstitutionMappingDictFromArgument'
,
text_content
=
'Test NM content ${username} AMOUNT (${amount}) WEBSITE(${website})'
,
content_type
=
'text/plain'
,
)
return
notification_message
.
getRelativeUrl
()
@
simulate
(
'Person_getSlapOSPendingTicket'
,
'*args, **kwargs'
,
'return range(99)'
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-crm-person-pending-ticket-notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["test_getSlapOSPendingTicketMessageTemplate"])'
)
def
test_getSlapOSPendingTicketMessageTemplate_with_notification_message
(
self
):
person
=
self
.
makePerson
()
self
.
portal
.
REQUEST
[
'test_getSlapOSPendingTicketMessageTemplate'
]
=
\
self
.
_makeNotificationMessage
()
title
,
message
=
person
.
Person_getSlapOSPendingTicketMessageTemplate
()
self
.
assertEqual
(
'Pending ticket'
,
title
)
self
.
assertEqual
(
'Test NM content Member Template AMOUNT (99) WEBSITE()'
,
message
)
class
TestSlapOSPerson_sendPendingTicketReminder
(
TestCRMSkinsMixin
):
@
simulate
(
'Person_getSlapOSPendingTicket'
,
'*args, **kwargs'
,
'return []'
)
@
simulate
(
'Person_sendSlapOSPendingTicketNotification'
,
'*args, **kwargs'
,
'assert False'
)
def
test_sendPendingTicketReminder
(
self
):
person
=
self
.
makePerson
()
# Script Person_sendSlapOSPendingTicketNotification not called
person
.
Person_sendPendingTicketReminder
()
@
simulate
(
'Person_getSlapOSPendingTicket'
,
'*args, **kwargs'
,
'return [1]'
)
@
simulate
(
'Person_sendSlapOSPendingTicketNotification'
,
'*args, **kwargs'
,
'context.REQUEST.set("test_getSlapOSPendingTicketMessageTemplate", "called")'
)
def
test_sendPendingTicketReminder_positive_amount
(
self
):
person
=
self
.
makePerson
()
person
.
Person_sendPendingTicketReminder
()
self
.
assertEqual
(
self
.
portal
.
REQUEST
[
"test_getSlapOSPendingTicketMessageTemplate"
],
"called"
)
class
TestSlapOSPerson_sendSlapOSPendingTicketNotification
(
TestCRMSkinsMixin
):
def
test_sendSlapOSPendingTicketNotification
(
self
):
person
=
self
.
makePerson
()
event
=
person
.
Person_sendSlapOSPendingTicketNotification
(
"TEST TITLE"
,
"TEST CONTENT"
,
batch_mode
=
1
)
self
.
tic
()
self
.
assertEqual
(
event
.
getTitle
(),
"TEST TITLE"
)
self
.
assertEqual
(
event
.
getTextContent
(),
"TEST CONTENT"
)
self
.
assertEqual
(
event
.
getSimulationState
(),
"started"
)
self
.
assertEqual
(
event
.
getPortalType
(),
"Mail Message"
)
self
.
assertEqual
(
event
.
getDestination
(),
person
.
getRelativeUrl
())
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