Commit 92d00418 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: drop SubscriptionRequest_processConfirmed

parent 43e29047
instance_tree = context.getAggregateValue()
if instance_tree is None:
# Probably we should raise here
return
# Instance is already destroyed so move into stopped state diretly.
if instance_tree.getValidationState() == "archived":
comment="Instance Tree is Destroyed and archived, Stop the Subscription Request"
context.start(comment=comment)
context.stop(comment=comment)
return comment
request_kw = dict(
software_release=instance_tree.getUrlString(),
software_title=instance_tree.getTitle(),
software_type=instance_tree.getSourceReference(),
instance_xml=instance_tree.getTextContent(),
sla_xml=instance_tree.getSlaXml(),
shared=instance_tree.isRootSlave(),
project_reference=instance_tree.getFollowUpReference()
)
if not context.SubscriptionRequest_testPaymentBalance():
# Payment isn't paid by the user, so we stop the instance and wait
if instance_tree.getSlapState() == "start_requested":
person = instance_tree.getDefaultDestinationSectionValue()
person.requestSoftwareInstance(state='stopped', **request_kw)
return "Skipped (Payment is pending)"
if instance_tree.getSlapState() == "stop_requested":
person = instance_tree.getDefaultDestinationSectionValue()
person.requestSoftwareInstance(state='started', **request_kw)
# Return to because it is useless continue right the way.
return "Skipped (Started instance)"
if not context.SubscriptionRequest_verifyInstanceIsAllocated():
# Only continue if instance is ready
return "Skipped (Instance is failing)"
if context.SubscriptionRequest_notifyInstanceIsReady():
context.start(comment="Instance is ready")
return "Instance is ready"
return "Skipped (Instance isn't ready)"
<?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>SubscriptionRequest_processConfirmed</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -1183,112 +1183,6 @@ class TestSubscriptionRequest_verifyInstanceIsAllocated(TestSubscriptionSkinsMix ...@@ -1183,112 +1183,6 @@ class TestSubscriptionRequest_verifyInstanceIsAllocated(TestSubscriptionSkinsMix
self.assertEqual( self.assertEqual(
subscription_request.SubscriptionRequest_verifyInstanceIsAllocated(), True) subscription_request.SubscriptionRequest_verifyInstanceIsAllocated(), True)
class TestSubscriptionRequest_processConfirmed(TestSubscriptionSkinsMixin):
def test_no_instance_tree(self):
person = self.makePerson()
subscription_request = self.newSubscriptionRequest(
quantity=1, destination_section_value=person,
url_string="https://%s/software.cfg" % self.new_id,
sla_xml="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oi">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""",
text_content="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="xx">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""",
root_slave=False,
source_reference="test_for_test_123")
subscription_request.plan()
subscription_request.order()
subscription_request.confirm()
self.tic()
self.assertEqual(
subscription_request.SubscriptionRequest_processConfirmed(), None)
self.tic()
self.assertEqual(subscription_request.getSimulationState(), "confirmed")
@simulate('SubscriptionRequest_testPaymentBalance', '', 'return False')
def test_instance_tree_is_stopped_due_unpaid_invoice(self):
person = self.makePerson()
subscription_request = self.newSubscriptionRequest(
quantity=1, destination_section_value=person,
url_string="https://%s/software.cfg" % self.new_id,
sla_xml="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oi">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""",
text_content="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="xx">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""",
root_slave=False,
source_reference="test_for_test_123")
subscription_request.plan()
subscription_request.order()
subscription_request.confirm()
self._makeTree()
subscription_request.edit(
aggregate_value=self.instance_tree
)
self.tic()
self.assertEqual(
subscription_request.SubscriptionRequest_processConfirmed(),
'Skipped (Payment is pending)')
self.tic()
self.assertEqual(subscription_request.getSimulationState(), "confirmed")
self.assertEqual(self.instance_tree.getSlapState(), "stop_requested")
@simulate('SubscriptionRequest_testPaymentBalance', '', 'return True')
def test_instance_tree_is_started_due_paid_invoice(self):
person = self.makePerson()
subscription_request = self.newSubscriptionRequest(
quantity=1, destination_section_value=person,
url_string="https://%s/software.cfg" % self.new_id,
sla_xml="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oi">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""",
text_content="""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="xx">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""",
root_slave=False,
source_reference="test_for_test_123")
subscription_request.plan()
subscription_request.order()
subscription_request.confirm()
self._makeTree()
subscription_request.edit(
aggregate_value=self.instance_tree
)
self.portal.portal_workflow._jumpToStateFor(self.instance_tree, 'stop_requested')
self.tic()
self.assertEqual(
subscription_request.SubscriptionRequest_processConfirmed(),
'Skipped (Started instance)')
self.tic()
self.assertEqual(subscription_request.getSimulationState(), "confirmed")
self.assertEqual(self.instance_tree.getSlapState(), "start_requested")
class TestSlapOSSubscriptionRequestModule_getTicketFeedUrl(TestSubscriptionSkinsMixin): class TestSlapOSSubscriptionRequestModule_getTicketFeedUrl(TestSubscriptionSkinsMixin):
......
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