Commit 2ab0f527 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: drop SubscriptionRequest_processRequest

parent 100dd3c0
if context.getAggregate() is not None:
return
subscription_condition = context.getSpecialiseValue(portal_type='Subscription Condition')
if subscription_condition is None:
return
person = context.getDestinationSectionValue()
if person is None:
return
if context.getSimulationState() == "confirmed":
return
request_kw = {}
default_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
if subscription_condition.getUrlString() is None:
raise ValueError("url_string cannot be None")
request_kw.update(
software_release=subscription_condition.getUrlString(),
# Bad title
software_title=context.getTitle() + " %s" % str(context.getUid()),
software_type=subscription_condition.getSourceReference("default"),
instance_xml = (subscription_condition.SubscriptionCondition_renderParameter(
amount=int(context.getQuantity())
) or default_xml).strip(),
sla_xml=subscription_condition.getSlaXml(default_xml).strip(),
shared=bool(subscription_condition.getRootSlave(0)),
state="started",
project_reference=subscription_condition.getFollowUpReference()
)
person.requestSoftwareInstance(**request_kw)
requested_software_instance = context.REQUEST.get('request_instance')
if requested_software_instance is None:
return
# Save the requested instance tree
context.setAggregate(requested_software_instance.getSpecialise())
<?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_processRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -672,74 +672,6 @@ class TestSubscriptionRequest_createRelatedSaleInvoiceTransaction(TestSubscripti ...@@ -672,74 +672,6 @@ class TestSubscriptionRequest_createRelatedSaleInvoiceTransaction(TestSubscripti
def test_creation_of_related_sale_invoice_transaction_q10(self): def test_creation_of_related_sale_invoice_transaction_q10(self):
self._test_creation_of_related_sale_invoice_transaction(10) self._test_creation_of_related_sale_invoice_transaction(10)
class SubscriptionRequest_processRequest(TestSubscriptionSkinsMixin):
def test_process_request_person_is_none(self):
subscription_request = self.newSubscriptionRequest(quantity=1)
self.assertEqual(None, subscription_request.SubscriptionRequest_processRequest())
def test_process_request_simulation_state(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.assertEqual(None, subscription_request.SubscriptionRequest_processRequest())
def test_process_request(self):
person = self.makePerson()
subscription_condition = self.newSubscriptionCondition(
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 = self.newSubscriptionRequest(
quantity=1, destination_section_value=person,
specialise_value=subscription_condition
)
self.tic()
subscription_request.SubscriptionRequest_processRequest()
software_instance = subscription_request.getAggregateValue(portal_type="Instance Tree")
self.assertEqual(software_instance.getSourceReference(), "test_for_test_123")
self.assertEqual(software_instance.getUrlString(), "https://%s/software.cfg" % self.new_id)
self.assertEqual(software_instance.getTextContent(), """<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="xx">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""")
self.assertEqual(software_instance.getSlaXml(), """<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oi">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>""")
self.assertEqual(software_instance.getSlapState(), "start_requested")
class TestSubscriptionRequest_sendAcceptedNotification(TestSubscriptionSkinsMixin): class TestSubscriptionRequest_sendAcceptedNotification(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