Commit 5a474470 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_pdm: Only cancel if Software Product is invalidated

parent 95e44779
......@@ -1336,16 +1336,22 @@ ${new_software_release_url}""",
def testUpgradeDecisionLine_cancel_archived_software_release(self):
software_release = self._makeSoftwareRelease()
software_product = self._makeSoftwareProduct()
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release])
software_release.setAggregateValue(software_product)
self.tic()
software_release.archive()
upgrade_decision_line.UpgradeDecisionLine_cancel()
self.assertEqual('draft', upgrade_decision.getSimulationState())
software_product.invalidate()
upgrade_decision_line.UpgradeDecisionLine_cancel()
self.assertEqual('cancelled', upgrade_decision.getSimulationState())
workflow_history_list = upgrade_decision.Base_getWorkflowHistoryItemList('upgrade_decision_workflow', display=0)
self.assertEqual("Software Release is archived.", workflow_history_list[-1].comment)
self.assertEqual("Software Product is invalidated.", workflow_history_list[-1].comment)
@simulate('NotificationTool_getDocumentValue',
'reference=None',
......@@ -1445,6 +1451,8 @@ ${new_software_release_url}""",
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr"])')
def testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr(self):
software_release = self._makeSoftwareRelease()
software_product = self._makeSoftwareProduct()
software_release.setAggregateValue(software_product)
instance_tree = self._makeFullInstanceTree(software_release.getUrlString())
upgrade_decision = self._makeUpgradeDecision()
......@@ -1478,9 +1486,10 @@ ${new_software_release_url}""",
)
instance_tree.requestDestroy(**kw)
software_release.archive()
software_product.invalidate()
self.tic()
upgrade_decision_line.UpgradeDecisionLine_cancel()
self.assertEqual('cancelled', upgrade_decision.getSimulationState())
workflow_history_list = upgrade_decision.Base_getWorkflowHistoryItemList('upgrade_decision_workflow', display=0)
self.assertEqual("Software Release is archived.", workflow_history_list[-1].comment)
self.assertEqual("Software Product is invalidated.", workflow_history_list[-1].comment)
......@@ -6,12 +6,6 @@
</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>testSlapOSPDMSkins</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</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>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
......@@ -10,7 +10,10 @@ if upgrade_decision.getSimulationState() == "cancelled":
return
if software_release.getValidationState() == "archived":
upgrade_decision.cancel(comment="Software Release is archived.")
software_product = software_release.getAggregateValue()
if software_product is not None and \
software_product.getValidationState() == "invalidated":
upgrade_decision.cancel(comment="Software Product is invalidated.")
return
if instance_tree is not None:
......
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