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: ...@@ -6,6 +6,9 @@ if REQUEST is not None:
portal = context.getPortalObject() portal = context.getPortalObject()
if context.getValidationState() != "validated":
raise ValueError("This Trial Condition isn't validated.")
trial_configuration = { trial_configuration = {
"instance_xml": context.getTextContent(), "instance_xml": context.getTextContent(),
"title": "%s for %s" % (context.getTitle(), email), "title": "%s for %s" % (context.getTitle(), email),
...@@ -39,11 +42,15 @@ if len(trial_request_list) >= 10: ...@@ -39,11 +42,15 @@ if len(trial_request_list) >= 10:
now = DateTime() 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( trial = context.trial_request_module.newContent(
source_reference=trial_configuration["software_type"], source_reference=trial_configuration["software_type"],
title=software_title, title=software_title,
url_string=trial_configuration["url"], url_string=trial_configuration["url"],
text_content=trial_configuration["instance_xml"] % user_input_dict, text_content=text_content,
start_date=now, start_date=now,
stop_date=now + 30, stop_date=now + 30,
root_slave=trial_configuration["shared"], root_slave=trial_configuration["shared"],
......
from DateTime import DateTime from DateTime import DateTime
portal = context.getPortalObject() portal = context.getPortalObject()
person = portal.portal_catalog.getResultValue( person = portal.portal_catalog.getResultValue(
portal_type="Person", portal_type="Person",
reference="free_trial_user") reference="free_trial_user")
if context.getStopDate() >= DateTime(): if context.getStopDate() >= DateTime():
return return
if person is None: if person is None:
return return
if context.getSpecialise() is None: if context.getSpecialise() is None:
return return
if context.getValidationState() != "validated": if context.getValidationState() != "validated":
return return
state = "destroyed" state = "destroyed"
...@@ -44,7 +44,7 @@ mapping_dict = {"token": connection_string } ...@@ -44,7 +44,7 @@ mapping_dict = {"token": connection_string }
context.TrialRequest_sendMailMessage(person, context.TrialRequest_sendMailMessage(person,
context.getDefaultEmailText(), context.getDefaultEmailText(),
'slapos-free.trial.destroy', 'slapos-free.trial.destroy',
mapping_dict) mapping_dict)
context.invalidate() context.invalidate()
...@@ -3,20 +3,20 @@ portal = context.getPortalObject() ...@@ -3,20 +3,20 @@ portal = context.getPortalObject()
notification_message = portal.portal_notifications.getDocumentValue( notification_message = portal.portal_notifications.getDocumentValue(
reference=notification_message_reference) 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() subject = notification_message.getTitle()
message = notification_message.asText( message = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict': mapping_dict}) substitution_method_parameter_dict={'mapping_dict': mapping_dict})
person_title = "%s FREE TRIAL" % email person_title = "%s FREE TRIAL" % email
free_trial_destination = portal.portal_catalog.getResultValue( free_trial_destination = portal.portal_catalog.getResultValue(
portal_type="Person", portal_type="Person",
title=person_title, title=person_title)
reference=None)
if free_trial_destination is None: if free_trial_destination is None:
free_trial_destination = portal.person_module.newContent( free_trial_destination = portal.person_module.newContent(
portal_type="Person", 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>
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixinWithAbort, simulate
from zExceptions import Unauthorized
from DateTime import DateTime
class TestTrialSkinsMixin(SlapOSTestCaseMixinWithAbort):
def _makeHostingSubscription(self):
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
return hosting_subscription
def _makeNotificationMessage(self, reference):
notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message",
title='TestTrialSkinsMixin Notification Message %s' % reference,
text_content='Test NM content<br/>%(input)s<br/>',
content_type='text/html',
reference=reference,
version="1",
language="en"
)
return notification_message
def makeFreeTrialUser(self):
person = self.portal.portal_catalog.getResultValue(
portal_type="Person",
reference="free_trial_user")
if person:
return person
person = self.makePerson()
person.setReference("free_trial_user")
self.tic()
return person
def newTrialCondition(self):
trial_condition = self.portal.trial_condition_module.newContent(
portal_type='Trial Condition',
title="Test Trial Condition %s" % self.new_id,
reference="TESTTRIALCONDITION-%s" % self.new_id
)
self.tic()
return trial_condition
def newTrialRequest(self, title=None, index=1, **kw):
if title is None:
title = title="Test Trial Request %s" % self.new_id
trial_request = self.portal.trial_request_module.newContent(
portal_type='Trial Request',
title=title,
reference="TESTTRIALREQUEST-%s" % self.new_id,
**kw
)
if index:
self.tic()
return trial_request
def afterSetUp(self):
self.setUpPersistentDummyMailHost()
SlapOSTestCaseMixinWithAbort.afterSetUp(self)
class TestSlapOSTrialCondition_requestFreeTrial(TestTrialSkinsMixin):
@simulate('TrialCondition_requestFreeTrialProxy', '*args, **kwargs','return args, kwargs')
def test(self):
trial_condition = self.newTrialCondition()
# Request is None, so it can only be called via URL
self.assertRaises(Unauthorized, trial_condition.TrialCondition_requestFreeTrial)
# Email not provided
self.assertRaises(ValueError, trial_condition.TrialCondition_requestFreeTrial,
REQUEST=self.portal.REQUEST)
expected_argument_tuple = (('123@nexedi.com',),
{'user_input_dict': {'input0': None, 'input1': None}, 'batch_mode': 0})
self.assertEqual(expected_argument_tuple, trial_condition.TrialCondition_requestFreeTrial(
REQUEST=self.portal.REQUEST, default_email_text="123@nexedi.com"))
expected_argument_tuple = (('123@nexedi.com',),
{'user_input_dict': {'input0': "couscous", 'input1': None}, 'batch_mode': 0})
self.assertEqual(expected_argument_tuple, trial_condition.TrialCondition_requestFreeTrial(
REQUEST=self.portal.REQUEST, default_input0="couscous",
default_email_text="123@nexedi.com"))
expected_argument_tuple = (('123@nexedi.com',),
{'user_input_dict': {'input0': None, 'input1': "couscous"}, 'batch_mode': 0})
self.assertEqual(expected_argument_tuple, trial_condition.TrialCondition_requestFreeTrial(
REQUEST=self.portal.REQUEST, default_input1="couscous",
default_email_text="123@nexedi.com"))
expected_argument_tuple = (('123@nexedi.com',),
{'user_input_dict': {'input0': "couscous", 'input1': "couscous1"}, 'batch_mode': 0})
self.assertEqual(expected_argument_tuple, trial_condition.TrialCondition_requestFreeTrial(
REQUEST=self.portal.REQUEST, default_input1="couscous1",
default_input0="couscous", default_email_text="123@nexedi.com"))
class TestSlapOSTrialCondition_requestFreeTrialProxy(TestTrialSkinsMixin):
def test_raises(self):
trial_condition = self.newTrialCondition()
# Request is not None so it can only be called via others scripts
self.assertRaises(Unauthorized, trial_condition.TrialCondition_requestFreeTrialProxy,
email="aa", REQUEST=self.portal.REQUEST)
# Trial resquest not validated
self.assertRaises(ValueError, trial_condition.TrialCondition_requestFreeTrialProxy,
email="aa")
trial_condition.validate()
# Do not raise
trial_condition.TrialCondition_requestFreeTrialProxy(email="aa")
def test_already_requested(self):
email = "123@nexedi.com"
trial_condition = self.newTrialCondition()
trial_condition.validate()
trial_request = self.newTrialRequest(
title= "%s for %s" % (trial_condition.getTitle(), email))
response = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email)
self.assertEqual(response, '"already-requested"')
trial_request.submit()
response = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email)
self.assertEqual(response, '"already-requested"')
def test_exceed_limit(self):
email = "123@nexedi.com"
trial_condition = self.newTrialCondition()
trial_condition.validate()
for _ in range(10):
trial_request = self.newTrialRequest(
title= "%s for %s" % (trial_condition.getTitle(), email),
index=0)
trial_request.submit()
trial_request.validate()
self.tic()
response = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email)
self.assertEqual(response, '"exceed-limit"')
def test_non_batch(self):
email = "123@nexedi.com"
trial_condition = self.newTrialCondition()
trial_condition.validate()
trial_request = self.newTrialRequest(
title= "%s for %s" % (trial_condition.getTitle(), email))
trial_request.submit()
trial_request.validate()
self.tic()
response = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email, batch_mode=0)
self.assertEqual(response, '"thank-you"')
def test_information_copied(self):
email = "123@nexedi.com"
trial_condition = self.newTrialCondition()
trial_condition.edit(
text_content="""
%(input)s
""",
source_reference="default",
url_string="http://lab.nexedi.com/nexedi/couscous",
root_slave=False,
subject_list=["input"],
sla_xml="""
ABC"""
)
trial_condition.validate()
trial_request = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email, user_input_dict={'input': "couscous"})
self.assertNotEqual(trial_request, None)
self.assertEqual(trial_request.getTextContent(), """
couscous
""")
self.assertEqual(trial_request.getSourceReference(), trial_condition.getSourceReference())
self.assertEqual(trial_request.getTitle(), "%s for %s" % (trial_condition.getTitle(), email))
self.assertNotEqual(trial_request.getStartDate(), None)
self.assertNotEqual(trial_request.getStopDate(), None)
self.assertTrue(trial_request.getStopDate() > DateTime())
self.assertTrue(trial_request.getStopDate() > DateTime() + 29)
self.assertTrue(trial_request.getStopDate() < DateTime() + 31)
self.assertEqual(trial_request.getRootSlave(), trial_condition.getRootSlave())
self.assertEqual(trial_request.getSubjectList(), trial_condition.getSubjectList())
self.assertEqual(trial_request.getUrlString(), trial_condition.getUrlString())
self.assertEqual(trial_request.getDefaultEmailText(), email)
class TestTrialRequest_processRequest(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog(
portal_type="Person",
reference="free_trial_user")
for person in person_list:
person.setReference("XXXX")
self.tic()
try:
trial_request = self.newTrialRequest()
self.assertEqual(None, trial_request.TrialRequest_processRequest())
self.assertEqual(None, trial_request.getAggregate())
finally:
for person in person_list:
person.setReference("free_trial_user")
self.tic()
def test_already_validated(self):
self.makeFreeTrialUser()
trial_request = self.newTrialRequest()
trial_request.validate()
self.assertEqual(None, trial_request.TrialRequest_processRequest())
self.assertEqual(None, trial_request.getAggregate())
def test(self):
email = "123@nexedi.com"
trial_condition = self.newTrialCondition()
trial_condition.edit(
text_content="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="abc">%(input)s</parameter>
</instance>""",
source_reference="default",
url_string="http://lab.nexedi.com/nexedi/couscous",
root_slave=False,
subject_list=["input"],
sla_xml="""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>"""
)
trial_condition.validate()
self.makeFreeTrialUser()
trial_request = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email, user_input_dict={'input': "couscous"})
self.assertNotEqual(None, trial_request)
self.assertEqual(None, trial_request.TrialRequest_processRequest())
self.assertNotEqual(None, trial_request.getSpecialise(portal_type="Hosting Subscription"))
self.assertNotEqual(None, trial_request.getAggregate(portal_type="Software Instance"))
self.assertEqual("submitted", trial_request.getValidationState())
specialise = trial_request.getSpecialise(portal_type="Hosting Subscription")
aggregate = trial_request.getAggregate(portal_type="Software Instance")
self.assertEqual(None, trial_request.TrialRequest_processRequest())
self.assertEqual(specialise, trial_request.getSpecialise(portal_type="Hosting Subscription"))
self.assertEqual(aggregate, trial_request.getAggregate(portal_type="Software Instance"))
class TestTrialRequest_processNotify(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog(
portal_type="Person",
reference="free_trial_user")
for person in person_list:
person.setReference("XXXX")
self.tic()
try:
trial_request = self.newTrialRequest()
self.assertEqual("Free Trial Person not Found", trial_request.TrialRequest_processNotify())
finally:
for person in person_list:
person.setReference("free_trial_user")
self.tic()
def test_already_validated(self):
self.makeFreeTrialUser()
trial_request = self.newTrialRequest()
trial_request.validate()
self.assertEqual(None, trial_request.TrialRequest_processNotify())
@simulate('TrialRequest_sendMailMessage', 'person, email, reference, mapping_dict',"""
if reference != "slapos-free.trial.token":
raise ValueError
if "token" not in mapping_dict:
raise ValueError
""")
def test_process_request(self):
email = "123@nexedi.com"
trial_condition = self.newTrialCondition()
trial_condition.edit(
text_content="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="abc">%(input)s</parameter>
</instance>""",
source_reference="default",
url_string="http://lab.nexedi.com/nexedi/couscous",
root_slave=False,
subject_list=["input"],
sla_xml="""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>"""
)
trial_condition.validate()
self.makeFreeTrialUser()
trial_request = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email, user_input_dict={'input': "couscous"})
self.assertNotEqual(None, trial_request)
self.assertEqual(None, trial_request.TrialRequest_processRequest())
instance = trial_request.getAggregateValue()
self.assertEqual("start_requested", instance.getSlapState())
self.assertEqual({}, instance.getConnectionXmlAsDict())
instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="aa">xx</parameter>
<parameter id="bb">yy</parameter>
</instance>
""")
self.assertEqual("Not ready [] != ['input']", trial_request.TrialRequest_processNotify())
# Key is there but value is None
instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="input">None</parameter>
<parameter id="bb">yy</parameter>
</instance>
""")
self.assertEqual("key input has invalid value None", trial_request.TrialRequest_processNotify())
# Key is there but value is http://
instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="input">http://</parameter>
<parameter id="bb">yy</parameter>
</instance>
""")
self.assertEqual("key input has invalid value http://", trial_request.TrialRequest_processNotify())
# Key is there but value is http://
instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="input">GOODVALUE</parameter>
<parameter id="bb">yy</parameter>
</instance>
""")
self.assertEqual(None, trial_request.TrialRequest_processNotify())
self.assertEqual("validated", trial_request.getValidationState())
class TestTrialRequest_sendMailMessage(TestTrialSkinsMixin):
# sender, email, notification_message_reference, mapping_dict
def test_notification_missing(self):
email = "testsender%s@nexedi.com" % self.new_id
notification_message_reference = "slapos-free.trial.token.%s" % self.new_id
trial_request = self.newTrialRequest()
self.assertRaises(ValueError, trial_request.TrialRequest_sendMailMessage,
None, email, notification_message_reference, {"token": "GOODTOKEN"})
def test_send_message(self):
sender = self.makeFreeTrialUser()
email = "testsender%s@nexedi.com" % self.new_id
notification_message_reference = "slapos-free.trial.token"
message = self._makeNotificationMessage(notification_message_reference)
message.validate()
trial_condition = self.newTrialCondition()
trial_condition.edit(
text_content="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="abc">%(input)s</parameter>
</instance>""",
source_reference="default",
url_string="http://lab.nexedi.com/nexedi/couscous",
root_slave=False,
subject_list=["input"],
sla_xml="""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>"""
)
trial_condition.validate()
trial_request = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email, user_input_dict={'input': "couscous"})
destination = self.portal.portal_catalog.getResultValue(
portal_type="Person",
title = "%s FREE TRIAL" % email)
self.assertEqual(None, destination)
event = trial_request.TrialRequest_sendMailMessage(
sender, email, notification_message_reference, {"token": "GOODTOKEN"})
self.assertNotEqual(None, event)
self.tic()
destination = self.portal.portal_catalog.getResultValue(
portal_type="Person",
title = "%s FREE TRIAL" % email)
self.assertNotEqual(None, destination)
self.assertEqual(email, destination.getDefaultEmailText())
self.assertEqual(event.getDestinationValue(), destination)
self.assertEqual(event.getSourceValue(), sender)
self.assertEqual(event.getSimulationState(), "delivered")
class TestTrialRequest_processDestroy(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog(
portal_type="Person",
reference="free_trial_user")
for person in person_list:
person.setReference("XXXX")
self.tic()
try:
trial_request = self.newTrialRequest()
trial_request.edit(stop_date=DateTime()-10,
specialise_value=self._makeHostingSubscription())
self.assertEqual(None, trial_request.TrialRequest_processDestroy())
finally:
for person in person_list:
person.setReference("free_trial_user")
self.tic()
def test_stop_date_didnt_arrive(self):
trial_request = self.newTrialRequest()
self.assertEqual(None, trial_request.TrialRequest_processDestroy())
def test_not_validated(self):
self.makeFreeTrialUser()
trial_request = self.newTrialRequest()
trial_request.edit(stop_date=DateTime()-10,
specialise_value=self._makeHostingSubscription())
self.assertEqual(None, trial_request.TrialRequest_processDestroy())
@simulate('TrialRequest_sendMailMessage', 'person, email, reference, mapping_dict',"""
if reference != "slapos-free.trial.destroy":
raise ValueError
if "token" not in mapping_dict:
raise ValueError
""")
def test_process_destroy(self):
email = "123@nexedi.com"
trial_condition = self.newTrialCondition()
trial_condition.edit(
text_content="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="abc">%(input)s</parameter>
</instance>""",
source_reference="default",
url_string="http://lab.nexedi.com/nexedi/couscous",
root_slave=False,
subject_list=["input"],
sla_xml="""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>"""
)
trial_condition.validate()
self.makeFreeTrialUser()
trial_request = trial_condition.TrialCondition_requestFreeTrialProxy(
email=email, user_input_dict={'input': "couscous"})
self.assertNotEqual(None, trial_request)
self.assertEqual(None, trial_request.TrialRequest_processRequest())
hosting_subscription = trial_request.getSpecialiseValue(portal_type="Hosting Subscription")
instance = trial_request.getAggregateValue(portal_type="Software Instance")
self.assertEqual("start_requested", hosting_subscription.getSlapState())
self.assertEqual("start_requested", instance.getSlapState())
trial_request.edit(stop_date=DateTime()-10)
instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="input">GOODVALUE</parameter>
<parameter id="bb">yy</parameter>
</instance>
""")
trial_request.validate()
self.tic()
self.assertEqual(None, trial_request.TrialRequest_processDestroy())
self.assertEqual("invalidated", trial_request.getValidationState())
self.tic()
self.assertEqual("destroy_requested", hosting_subscription.getSlapState(), hosting_subscription.getRelativeUrl())
self.assertEqual("destroy_requested", instance.getSlapState())
<?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