Commit ddeb07f6 authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_pdm: add test for UpgradeDecision_requestChangeState

parent 670507ea
......@@ -15,12 +15,9 @@ computer = context.UpgradeDecision_getComputer()
software_release = context.UpgradeDecision_getSoftwareRelease()
software_product_title = software_release.getAggregateTitle(
portal_type="Software Product")
reference = context.getReference()
mapping_dict = {
'software_product_title': software_product_title,
'upgrade_accept_link': 'Base_acceptUpgradeDecision?reference=%s' % reference,
'upgrade_reject_link': 'Base_rejectUpgradeDecision?reference=%s' % reference,
'software_release_name': software_release.getTitle(),
'software_release_reference': software_release.getReference(),
'new_software_release_url': software_release.getUrlString(),
......
......@@ -1499,6 +1499,48 @@ class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
self.tic()
self.assertTrue(upgrade_decision.UpgradeDecision_isUpgradeFinished())
def testUpgradeDecision_requestChangeState_started(self):
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.setReference("UD-TESTDECISION")
upgrade_decision.confirm()
requested_state = "started"
self.assertEquals(upgrade_decision.getSimulationState(), 'confirmed')
upgrade_decision.UpgradeDecision_requestChangeState(requested_state)
self.assertEquals(upgrade_decision.getSimulationState(), 'started')
def testUpgradeDecision_requestChangeState_reject(self):
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.setReference("UD-TESTDECISION")
upgrade_decision.confirm()
requested_state = "rejected"
self.assertEquals(upgrade_decision.getSimulationState(), 'confirmed')
upgrade_decision.UpgradeDecision_requestChangeState(requested_state)
self.assertEquals(upgrade_decision.getSimulationState(), 'rejected')
def testUpgradeDecision_requestChangeState_stopped(self):
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.setReference("UD-TESTDECISION")
upgrade_decision.confirm()
upgrade_decision.stop()
requested_state = "started"
self.assertEquals(upgrade_decision.getSimulationState(), 'stopped')
result = upgrade_decision.UpgradeDecision_requestChangeState(requested_state)
self.assertEquals(upgrade_decision.getSimulationState(), 'stopped')
self.assertEquals(result, "Transition from state %s to %s is not permitted" % (
upgrade_decision.getSimulationState(), requested_state))
def testUpgradeDecision_requestChangeState_rejected(self):
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.setReference("UD-TESTDECISION")
upgrade_decision.confirm()
upgrade_decision.start()
requested_state = "rejected"
self.assertEquals(upgrade_decision.getSimulationState(), 'started')
result = upgrade_decision.UpgradeDecision_requestChangeState(requested_state)
self.assertEquals(upgrade_decision.getSimulationState(), 'started')
self.assertEquals(result, "Transition from state %s to %s is not permitted" % (
upgrade_decision.getSimulationState(), requested_state))
def testUpgradeDecision_isUpgradeFinished_hosting_subscription(self):
hosting_subscription = self._makeHostingSubscription()
software_release = self._makeSoftwareRelease()
......@@ -1540,8 +1582,6 @@ ${computer_title}
${computer_reference}
${software_release_name}
${software_release_reference}
${upgrade_accept_link}
${upgrade_reject_link}
${new_software_release_url}""",
content_type='text/html',
)
......@@ -1571,8 +1611,6 @@ ${new_software_release_url}""",
self.assertEqual(event.getTextContent().splitlines(),
[software_product.getTitle(), computer.getTitle(), computer.getReference(),
software_release.getTitle(), software_release.getReference(),
'Base_acceptUpgradeDecision?reference=%s' % upgrade_decision.getReference(),
'Base_rejectUpgradeDecision?reference=%s' % upgrade_decision.getReference(),
software_release.getUrlString()])
......@@ -1607,8 +1645,6 @@ ${hosting_subscription_title}
${old_software_release_url}
${software_release_name}
${software_release_reference}
${upgrade_accept_link}
${upgrade_reject_link}
${new_software_release_url}""",
content_type='text/html',
)
......@@ -1638,8 +1674,6 @@ ${new_software_release_url}""",
self.assertEqual(event.getTextContent().splitlines(),
[software_product.getTitle(), hosting_subscription.getTitle(),
old_url, software_release.getTitle(), software_release.getReference(),
'Base_acceptUpgradeDecision?reference=%s' % upgrade_decision.getReference(),
'Base_rejectUpgradeDecision?reference=%s' % upgrade_decision.getReference(),
software_release.getUrlString()])
self.assertEquals(event.getSimulationState(), "delivered")
......
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