Commit 7401b8bd authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Add Tests for Trial Request Skins & Alarms

parent 4d430168
......@@ -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=trial_configuration["instance_xml"] % user_input_dict,
text_content=text_content,
start_date=now,
stop_date=now + 30,
root_slave=trial_configuration["shared"],
......
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()
......@@ -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",
......
# 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)
<?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>
<?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>
test.erp5.testSlapOSTrialSkins
test.erp5.testSlapOSTrialAlarm
\ No newline at end of file
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