Commit a2117809 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_pdm: Include script for confirm if Upgrade was already requested

parent c106dded
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
\n
hosting_subscription = context.UpgradeDecision_getHostingSubscription()\n
computer = context.UpgradeDecision_getComputer()\n
software_release = context.UpgradeDecision_getSoftwareRelease()\n
\n
if hosting_subscription is not None:\n
if hosting_subscription.getUrlString() == software_release.getUrlString():\n
return True\n
\n
elif computer is not None:\n
full_software_release_list = [si for si in \n
portal.portal_catalog(\n
portal_type=\'Software Installation\',\n
url_string=software_release.getUrlString(),\n
default_aggregate_uid=computer.getUid(),\n
validation_state=\'validated\'\n
) if si.getSlapState() == \'start_requested\']\n
\n
if len(full_software_release_list) > 0:\n
return True\n
\n
return False\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>UpgradeDecision_isUpgradeFinished</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -1394,6 +1394,37 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
"?portal_status_message=Upgrade%20Decision%20is%20already%20Rejected%21"),
"%s contains the wrong message" % redirect_url)
def testUpgradeDecision_isUpgradeFinished_computer(self):
computer = self._makeComputer(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, computer])
upgrade_decision.confirm()
upgrade_decision.stop()
self.assertFalse(upgrade_decision.UpgradeDecision_isUpgradeFinished())
self._makeSoftwareInstallation(self.new_id, computer,
software_release.getUrlString())
self.tic()
self.assertTrue(upgrade_decision.UpgradeDecision_isUpgradeFinished())
def testUpgradeDecision_isUpgradeFinished_hosting_subscription(self):
hosting_subscription = self._makeHostingSubscription(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release,
hosting_subscription])
upgrade_decision.confirm()
upgrade_decision.stop()
self.assertFalse(upgrade_decision.UpgradeDecision_isUpgradeFinished())
hosting_subscription.setUrlString(software_release.getUrlString())
self.assertTrue(upgrade_decision.UpgradeDecision_isUpgradeFinished())
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-upgrade-computer.notification"\n' \
......@@ -1524,4 +1555,4 @@ ${new_software_release_url}""",
self.assertEquals(event.getSimulationState(), "delivered")
\ 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