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
Carlos Ramos Carreño
slapos.core
Commits
7401b8bd
Commit
7401b8bd
authored
Jan 03, 2019
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Add Tests for Trial Request Skins & Alarms
parent
4d430168
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
884 additions
and
11 deletions
+884
-11
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/TrialCondition_requestFreeTrialProxy.py
...scription_request/TrialCondition_requestFreeTrialProxy.py
+8
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/TrialRequest_processDestroy.py
...lapos_subscription_request/TrialRequest_processDestroy.py
+6
-6
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/TrialRequest_sendMailMessage.py
...apos_subscription_request/TrialRequest_sendMailMessage.py
+4
-4
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialAlarm.py
...eItem/portal_components/test.erp5.testSlapOSTrialAlarm.py
+74
-0
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialAlarm.xml
...Item/portal_components/test.erp5.testSlapOSTrialAlarm.xml
+123
-0
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialSkins.py
...eItem/portal_components/test.erp5.testSlapOSTrialSkins.py
+544
-0
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialSkins.xml
...Item/portal_components/test.erp5.testSlapOSTrialSkins.xml
+123
-0
master/bt5/slapos_subscription_request/bt/template_test_id_list
.../bt5/slapos_subscription_request/bt/template_test_id_list
+2
-0
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/TrialCondition_requestFreeTrialProxy.py
View file @
7401b8bd
...
...
@@ -6,6 +6,9 @@ if REQUEST is not None:
portal
=
context
.
getPortalObject
()
if
context
.
getValidationState
()
!=
"validated"
:
raise
ValueError
(
"This Trial Condition isn't validated."
)
trial_configuration
=
{
"instance_xml"
:
context
.
getTextContent
(),
"title"
:
"%s for %s"
%
(
context
.
getTitle
(),
email
),
...
...
@@ -39,11 +42,15 @@ if len(trial_request_list) >= 10:
now
=
DateTime
()
text_content
=
trial_configuration
.
get
(
"instance_xml"
)
if
text_content
is
not
None
:
text_content
=
text_content
%
user_input_dict
trial
=
context
.
trial_request_module
.
newContent
(
source_reference
=
trial_configuration
[
"software_type"
],
title
=
software_title
,
url_string
=
trial_configuration
[
"url"
],
text_content
=
t
rial_configuration
[
"instance_xml"
]
%
user_input_dic
t
,
text_content
=
t
ext_conten
t
,
start_date
=
now
,
stop_date
=
now
+
30
,
root_slave
=
trial_configuration
[
"shared"
],
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/TrialRequest_processDestroy.py
View file @
7401b8bd
from
DateTime
import
DateTime
portal
=
context
.
getPortalObject
()
person
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Person"
,
portal_type
=
"Person"
,
reference
=
"free_trial_user"
)
if
context
.
getStopDate
()
>=
DateTime
():
return
return
if
person
is
None
:
return
if
person
is
None
:
return
if
context
.
getSpecialise
()
is
None
:
return
if
context
.
getValidationState
()
!=
"validated"
:
return
return
state
=
"destroyed"
...
...
@@ -44,7 +44,7 @@ mapping_dict = {"token": connection_string }
context
.
TrialRequest_sendMailMessage
(
person
,
context
.
getDefaultEmailText
(),
'slapos-free.trial.destroy'
,
'slapos-free.trial.destroy'
,
mapping_dict
)
context
.
invalidate
()
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/TrialRequest_sendMailMessage.py
View file @
7401b8bd
...
...
@@ -3,20 +3,20 @@ portal = context.getPortalObject()
notification_message
=
portal
.
portal_notifications
.
getDocumentValue
(
reference
=
notification_message_reference
)
if
notification_message
is
None
:
raise
ValueError
(
"Notification Message with reference %s was not found"
%
notification_message_reference
)
subject
=
notification_message
.
getTitle
()
message
=
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
mapping_dict
})
person_title
=
"%s FREE TRIAL"
%
email
free_trial_destination
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Person"
,
title
=
person_title
,
reference
=
None
)
title
=
person_title
)
if
free_trial_destination
is
None
:
free_trial_destination
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
...
...
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialAlarm.py
0 → 100644
View file @
7401b8bd
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
from
erp5.component.test.SlapOSTestCaseMixin
import
\
SlapOSTestCaseMixin
from
DateTime
import
DateTime
class
TestSlapOSTrialRequestProcessDraft
(
SlapOSTestCaseMixin
):
def
test_alarm_slapos_trial_process_draft_trial_request
(
self
):
script_name
=
"TrialRequest_processRequest"
alarm
=
self
.
portal
.
portal_alarms
.
slapos_trial_process_draft_trial_request
trial_request
=
self
.
portal
.
trial_request_module
.
newContent
(
portal_type
=
'Trial Request'
,
title
=
"Test Trial Request %s"
%
self
.
new_id
,
reference
=
"TESTTRIALREQUEST-%s"
%
self
.
new_id
)
self
.
_test_alarm
(
alarm
,
trial_request
,
script_name
)
def
test_alarm_slapos_trial_process_submitted_trial_request
(
self
):
script_name
=
"TrialRequest_processNotify"
alarm
=
self
.
portal
.
portal_alarms
.
slapos_trial_process_submitted_trial_request
trial_request
=
self
.
portal
.
trial_request_module
.
newContent
(
portal_type
=
'Trial Request'
,
title
=
"Test Trial Request %s"
%
self
.
new_id
,
reference
=
"TESTTRIALREQUEST-%s"
%
self
.
new_id
)
trial_request
.
submit
()
self
.
_test_alarm
(
alarm
,
trial_request
,
script_name
)
def
test_alarm_slapos_trial_process_validated_trial_request
(
self
):
script_name
=
"TrialRequest_processDestroy"
alarm
=
self
.
portal
.
portal_alarms
.
slapos_trial_process_validated_trial_request
trial_request
=
self
.
portal
.
trial_request_module
.
newContent
(
portal_type
=
'Trial Request'
,
title
=
"Test Trial Request %s"
%
self
.
new_id
,
reference
=
"TESTTRIALREQUEST-%s"
%
self
.
new_id
)
trial_request
.
submit
()
trial_request
.
validate
()
def
getCreationDate
(
self
):
return
DateTime
()
-
2
from
Products.ERP5Type.Base
import
Base
original_get_creation
=
Base
.
getCreationDate
Base
.
getCreationDate
=
getCreationDate
try
:
self
.
_test_alarm
(
alarm
,
trial_request
,
script_name
)
finally
:
Base
.
getCreationDate
=
original_get_creation
def
test_alarm_slapos_trial_process_validated_trial_request_too_soon
(
self
):
script_name
=
"TrialRequest_processDestroy"
alarm
=
self
.
portal
.
portal_alarms
.
slapos_trial_process_validated_trial_request
trial_request
=
self
.
portal
.
trial_request_module
.
newContent
(
portal_type
=
'Trial Request'
,
title
=
"Test Trial Request %s"
%
self
.
new_id
,
reference
=
"TESTTRIALREQUEST-%s"
%
self
.
new_id
)
trial_request
.
submit
()
trial_request
.
validate
()
self
.
_test_alarm_not_visited
(
alarm
,
trial_request
,
script_name
)
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialAlarm.xml
0 → 100644
View file @
7401b8bd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSTrialAlarm
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testSlapOSTrialAlarm
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialSkins.py
0 → 100644
View file @
7401b8bd
This diff is collapsed.
Click to expand it.
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSTrialSkins.xml
0 → 100644
View file @
7401b8bd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSTrialSkins
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testSlapOSTrialSkins
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/bt/template_test_id_list
0 → 100644
View file @
7401b8bd
test.erp5.testSlapOSTrialSkins
test.erp5.testSlapOSTrialAlarm
\ No newline at end of file
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