Commit 576b7681 authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: lint test

parent 10740fb9
...@@ -35,9 +35,8 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin): ...@@ -35,9 +35,8 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin):
state="started" state="started"
) )
def _makePerson(self): def _makePerson(self, project):
person_user = self.makePerson(new_id=self.new_id) return self.makePerson(project, new_id=self.new_id)
return person_user
def _makeComputePartitions(self, compute_node): def _makeComputePartitions(self, compute_node):
for i in range(1, 5): for i in range(1, 5):
...@@ -50,16 +49,16 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin): ...@@ -50,16 +49,16 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin):
default_network_address_netmask='netmask_%s' % i) default_network_address_netmask='netmask_%s' % i)
p.markFree() p.markFree()
p.validate() p.validate()
def _markComputePartitionBusy(self, compute_node, software_instance): def _markComputePartitionBusy(self, compute_node, software_instance):
for partition in compute_node.contentValues(portal_type='Compute Partition'): for partition in compute_node.contentValues(portal_type='Compute Partition'):
if partition.getSlapState() == 'free': if partition.getSlapState() == 'free':
software_instance.edit(aggregate=partition.getRelativeUrl()) software_instance.edit(aggregate=partition.getRelativeUrl())
partition.markBusy() partition.markBusy()
break break
def _requestSoftwareRelease(self, software_product_url, effective_date=None): def _requestSoftwareRelease(self, software_product_url, effective_date=None):
software_release = self._makeSoftwareRelease() software_release = self._makeSoftwareRelease(self.project)
if not effective_date: if not effective_date:
effective_date = DateTime() effective_date = DateTime()
software_release.edit( software_release.edit(
...@@ -68,15 +67,9 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin): ...@@ -68,15 +67,9 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin):
) )
software_release.publish() software_release.publish()
return software_release return software_release
def _makeCustomSoftwareRelease(self, software_product_url, software_url): def _makeCustomSoftwareRelease(self, software_product, software_url):
software_release = self._makeSoftwareRelease() return self._makeSoftwareRelease(software_product, url=software_url)
software_release.edit(
aggregate_value=software_product_url,
url_string=software_url
)
software_release.publish()
return software_release
def _makeSoftwareInstallation(self, compute_node, software_release_url): def _makeSoftwareInstallation(self, compute_node, software_release_url):
software_installation = self.portal\ software_installation = self.portal\
...@@ -120,9 +113,9 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin): ...@@ -120,9 +113,9 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin):
instance_tree.requestStart(**kw) instance_tree.requestStart(**kw)
instance_tree.requestInstance(**kw) instance_tree.requestInstance(**kw)
def _makeFullInstanceTree(self, software_url="", person=None): def _makeFullInstanceTree(self, project, software_url="", person=None):
if not person: if not person:
person = self._makePerson() person = self._makePerson(project)
instance_tree = self.portal\ instance_tree = self.portal\
.instance_tree_module.template_instance_tree\ .instance_tree_module.template_instance_tree\
...@@ -186,25 +179,26 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -186,25 +179,26 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.tic() self.tic()
def test_getSortedSoftwareReleaseListFromSoftwareProduct(self): def test_getSortedSoftwareReleaseListFromSoftwareProduct(self):
software_product = self._makeSoftwareProduct() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList( release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList(
software_product.getReference()) software_product.getReference())
self.assertEqual(release_list, []) self.assertEqual(release_list, [])
# published software release # published software release
software_release1 = self._makeSoftwareRelease() software_release1 = self._makeSoftwareRelease(software_product)
software_release1.edit(aggregate_value=software_product.getRelativeUrl(), software_release1.edit(aggregate_value=software_product.getRelativeUrl(),
url_string='http://example.org/1-%s.cfg' % self.new_id, url_string='http://example.org/1-%s.cfg' % self.new_id,
effective_date=(DateTime() + 5) effective_date=(DateTime() + 5)
) )
software_release1.publish() software_release1.publish()
software_release2 = self._makeSoftwareRelease() software_release2 = self._makeSoftwareRelease(software_product)
software_release2.edit(aggregate_value=software_product.getRelativeUrl(), software_release2.edit(aggregate_value=software_product.getRelativeUrl(),
url_string='http://example.org/2-%s.cfg' % self.new_id url_string='http://example.org/2-%s.cfg' % self.new_id
) )
software_release2.publish() software_release2.publish()
# 1 released software release, should not appear # 1 released software release, should not appear
software_release3 = self._makeSoftwareRelease() software_release3 = self._makeSoftwareRelease(software_product)
self.assertTrue(software_release3.getValidationState() == 'released') self.assertTrue(software_release3.getValidationState() == 'released')
software_release3.edit(aggregate_value=software_product.getRelativeUrl(), software_release3.edit(aggregate_value=software_product.getRelativeUrl(),
url_string='http://example.org/3-%s.cfg' % self.new_id url_string='http://example.org/3-%s.cfg' % self.new_id
...@@ -217,20 +211,21 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -217,20 +211,21 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
['http://example.org/2-%s.cfg' % self.new_id, 'http://example.org/1-%s.cfg' % self.new_id]) ['http://example.org/2-%s.cfg' % self.new_id, 'http://example.org/1-%s.cfg' % self.new_id])
def test_getSortedSoftwareReleaseListFromSoftwareProduct_Changed(self): def test_getSortedSoftwareReleaseListFromSoftwareProduct_Changed(self):
software_product = self._makeSoftwareProduct() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList( release_list = software_product.SoftwareProduct_getSortedSoftwareReleaseList(
software_product.getReference()) software_product.getReference())
self.assertEqual(release_list, []) self.assertEqual(release_list, [])
# 2 published software releases # 2 published software releases
software_release2 = self._makeSoftwareRelease() software_release2 = self._makeSoftwareRelease(software_product)
software_release2.publish() software_release2.publish()
software_release2.edit(aggregate_value=software_product.getRelativeUrl(), software_release2.edit(aggregate_value=software_product.getRelativeUrl(),
url_string='http://example.org/2-%s.cfg' % self.new_id, url_string='http://example.org/2-%s.cfg' % self.new_id,
effective_date=(DateTime() - 2) effective_date=(DateTime() - 2)
) )
# Newest software release # Newest software release
software_release1 = self._makeSoftwareRelease() software_release1 = self._makeSoftwareRelease(software_product)
software_release1.publish() software_release1.publish()
software_release1.edit(aggregate_value=software_product.getRelativeUrl(), software_release1.edit(aggregate_value=software_product.getRelativeUrl(),
url_string='http://example.org/1-%s.cfg' % self.new_id, url_string='http://example.org/1-%s.cfg' % self.new_id,
...@@ -249,9 +244,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -249,9 +244,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
def test_InstanceTree_getNewerSofwareRelease(self): def test_InstanceTree_getNewerSofwareRelease(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode(owner=person) person = self._makePerson(project)
software_product = self._makeSoftwareProduct() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct(project)
oldest_software_url = 'http://example.org/oldest-%s.cfg' % self.new_id oldest_software_url = 'http://example.org/oldest-%s.cfg' % self.new_id
newest_software_url = 'http://example.org/newest-%s.cfg' % self.new_id newest_software_url = 'http://example.org/newest-%s.cfg' % self.new_id
...@@ -274,10 +270,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -274,10 +270,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(release.getUrlString(), newest_software_url) self.assertEqual(release.getUrlString(), newest_software_url)
def testInstanceTree_getUpgradableSoftwareRelease_no_installation(self): def testInstanceTree_getUpgradableSoftwareRelease_no_installation(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode(owner=person) person = self._makePerson(project)
compute_node, _ = self._makeComputeNode(project)
self._makeComputePartitions(compute_node) self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
oldest_software_url = 'http://example.org/oldest-%s.cfg' % self.new_id oldest_software_url = 'http://example.org/oldest-%s.cfg' % self.new_id
newest_software_url = 'http://example.org/newest-%s.cfg' % self.new_id newest_software_url = 'http://example.org/newest-%s.cfg' % self.new_id
self._makeCustomSoftwareRelease( self._makeCustomSoftwareRelease(
...@@ -299,10 +296,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -299,10 +296,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
None) None)
def testInstanceTree_getUpgradableSoftwareRelease(self): def testInstanceTree_getUpgradableSoftwareRelease(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode(owner=person) person = self._makePerson(project)
compute_node, _ = self._makeComputeNode(project)
self._makeComputePartitions(compute_node) self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
oldest_software_url = 'http://example.org/oldest-%s.cfg' % self.new_id oldest_software_url = 'http://example.org/oldest-%s.cfg' % self.new_id
newest_software_url = 'http://example.org/newest-%s.cfg' % self.new_id newest_software_url = 'http://example.org/newest-%s.cfg' % self.new_id
self._makeCustomSoftwareRelease( self._makeCustomSoftwareRelease(
...@@ -311,7 +309,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -311,7 +309,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self._makeSoftwareInstallation( compute_node, oldest_software_url) self._makeSoftwareInstallation( compute_node, oldest_software_url)
hs = self._makeFullInstanceTree( hs = self._makeFullInstanceTree(
oldest_software_url, person) oldest_software_url, person)
self._makeFullSoftwareInstance(hs, oldest_software_url) self._makeFullSoftwareInstance(hs, oldest_software_url)
self._markComputePartitionBusy(compute_node, hs.getSuccessorValue()) self._markComputePartitionBusy(compute_node, hs.getSuccessorValue())
self._makeCustomSoftwareRelease(software_product.getRelativeUrl(), self._makeCustomSoftwareRelease(software_product.getRelativeUrl(),
...@@ -319,20 +317,20 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -319,20 +317,20 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self._makeSoftwareInstallation(compute_node, self._makeSoftwareInstallation(compute_node,
newest_software_url) newest_software_url)
# software_release should be ignored! # software_release should be ignored!
software_release = self._makeSoftwareRelease() software_release = self._makeSoftwareRelease(software_product)
self._makeSoftwareInstallation(compute_node, software_release.getUrlString()) self._makeSoftwareInstallation(compute_node, software_release.getUrlString())
self.tic() self.tic()
release = hs.InstanceTree_getUpgradableSoftwareRelease() release = hs.InstanceTree_getUpgradableSoftwareRelease()
self.assertEqual(release.getUrlString(), newest_software_url) self.assertEqual(release.getUrlString(), newest_software_url)
self.portal.portal_workflow._jumpToStateFor(hs, 'destroy_requested') self.portal.portal_workflow._jumpToStateFor(hs, 'destroy_requested')
self.tic() self.tic()
self.assertEqual(hs.InstanceTree_getUpgradableSoftwareRelease(), self.assertEqual(hs.InstanceTree_getUpgradableSoftwareRelease(),
None) None)
def testUpgradeDecision_getComputeNode(self): def testUpgradeDecision_getComputeNode(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -343,7 +341,8 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -343,7 +341,8 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
found_compute_node.getRelativeUrl()) found_compute_node.getRelativeUrl())
def testUpgradeDecision_getComputeNode_2_lines(self): def testUpgradeDecision_getComputeNode_2_lines(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -356,7 +355,8 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -356,7 +355,8 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
found_compute_node.getRelativeUrl()) found_compute_node.getRelativeUrl())
def testUpgradeDecision_getComputeNode_2_compute_node(self): def testUpgradeDecision_getComputeNode_2_compute_node(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -422,9 +422,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -422,9 +422,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
found_instance_tree = upgrade_decision.UpgradeDecision_getAggregateValue("Instance Tree") found_instance_tree = upgrade_decision.UpgradeDecision_getAggregateValue("Instance Tree")
self.assertEqual(None, found_instance_tree) self.assertEqual(None, found_instance_tree)
def testUpgradeDecision_getAggregateValue_SoftwareRelease(self): def testUpgradeDecision_getAggregateValue_SoftwareRelease(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -435,7 +436,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -435,7 +436,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
found_software_release.getRelativeUrl()) found_software_release.getRelativeUrl())
def testUpgradeDecision_getAggregateValue_SoftwareRelease_2_lines(self): def testUpgradeDecision_getAggregateValue_SoftwareRelease_2_lines(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -448,7 +451,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -448,7 +451,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
found_software_release.getRelativeUrl()) found_software_release.getRelativeUrl())
def testUpgradeDecision_getAggregateValue_SoftwareRelease_2_sr(self): def testUpgradeDecision_getAggregateValue_SoftwareRelease_2_sr(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -479,10 +484,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -479,10 +484,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(software_release.getUrlString(), url_string) self.assertEqual(software_release.getUrlString(), url_string)
def testSoftwareRelease_createUpgradeDecision_compute_node(self): def testSoftwareRelease_createUpgradeDecision_compute_node(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode(owner=person) person = self._makePerson(project)
software_release = self._makeSoftwareRelease() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = software_release.SoftwareRelease_createUpgradeDecision( upgrade_decision = software_release.SoftwareRelease_createUpgradeDecision(
source_url=compute_node.getRelativeUrl(), source_url=compute_node.getRelativeUrl(),
title="TEST-SRUPDE-%s" % self.new_id) title="TEST-SRUPDE-%s" % self.new_id)
...@@ -506,11 +513,13 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -506,11 +513,13 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
def testSoftwareRelease_createUpgradeDecision_hostingSubscription(self): def testSoftwareRelease_createUpgradeDecision_hostingSubscription(self):
person = self._makePerson() project = self.addProject()
person = self._makePerson(project)
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
instance_tree.edit( instance_tree.edit(
destination_section_value = person.getRelativeUrl()) destination_section_value = person.getRelativeUrl())
software_release = self._makeSoftwareRelease() software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = software_release.SoftwareRelease_createUpgradeDecision( upgrade_decision = software_release.SoftwareRelease_createUpgradeDecision(
source_url=instance_tree.getRelativeUrl(), source_url=instance_tree.getRelativeUrl(),
...@@ -531,14 +540,15 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -531,14 +540,15 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
def testSoftwareRelease_getUpgradeDecisionInProgress(self): def testSoftwareRelease_getUpgradeDecisionInProgress(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
software_product = self._makeSoftwareProduct() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, compute_node]) upgrade_decision_line.setAggregateValueList([software_release, compute_node])
software_release2 = self._makeSoftwareRelease() software_release2 = self._makeSoftwareRelease(software_product)
upgrade_decision.confirm() upgrade_decision.confirm()
reference = upgrade_decision.getReference() reference = upgrade_decision.getReference()
...@@ -557,8 +567,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -557,8 +567,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(in_progress, None) self.assertEqual(in_progress, None)
def testSoftwareRelease_getUpgradeDecisionInProgress_cancelled(self): def testSoftwareRelease_getUpgradeDecisionInProgress_cancelled(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
software_product = self._makeSoftwareProduct() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
...@@ -584,8 +595,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -584,8 +595,9 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(in_progress.getReference(), upgrade_decision2.getReference()) self.assertEqual(in_progress.getReference(), upgrade_decision2.getReference())
def testSoftwareRelease_getUpgradeDecisionInProgress_rejected(self): def testSoftwareRelease_getUpgradeDecisionInProgress_rejected(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
software_product = self._makeSoftwareProduct() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
...@@ -620,11 +632,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -620,11 +632,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(in_progress.getReference(), upgrade_decision2.getReference()) self.assertEqual(in_progress.getReference(), upgrade_decision2.getReference())
def testSoftwareRelease_getUpgradeDecisionInProgress_hosting_subs(self): def testSoftwareRelease_getUpgradeDecisionInProgress_hosting_subs(self):
person = self._makePerson() project = self.addProject()
person = self._makePerson(project)
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
instance_tree.edit( instance_tree.edit(
destination_section_value = person.getRelativeUrl()) destination_section_value = person.getRelativeUrl())
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
...@@ -648,13 +661,14 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -648,13 +661,14 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
def testSoftwareRelease_getUpgradeDecisionInProgress_software_product(self): def testSoftwareRelease_getUpgradeDecisionInProgress_software_product(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
software_product = self._makeSoftwareProduct() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
software_release3 = self._makeSoftwareRelease() software_release3 = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, compute_node]) upgrade_decision_line.setAggregateValueList([software_release, compute_node])
...@@ -677,16 +691,17 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -677,16 +691,17 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
def testSoftwareRelease_getUpgradeDecisionInProgress_software_product_hs(self): def testSoftwareRelease_getUpgradeDecisionInProgress_software_product_hs(self):
person = self._makePerson() project = self.addProject()
person = self._makePerson(project)
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
instance_tree.edit( instance_tree.edit(
destination_section_value = person.getRelativeUrl()) destination_section_value = person.getRelativeUrl())
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl()) software_product.getRelativeUrl())
software_release3 = self._makeSoftwareRelease() software_release3 = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, upgrade_decision_line.setAggregateValueList([software_release,
...@@ -711,13 +726,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -711,13 +726,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
def testComputeNode_checkAndCreateUpgradeDecision_auto(self): def testComputeNode_checkAndCreateUpgradeDecision_auto(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode(owner=person, compute_node, _ = self._makeComputeNode(project,
allocation_scope="open") allocation_scope="open")
compute_node.edit(upgrade_scope="auto") compute_node.edit(upgrade_scope="auto")
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._makeSoftwareRelease(software_product)
software_product.getRelativeUrl())
self._makeSoftwareInstallation( self._makeSoftwareInstallation(
compute_node, software_release.getUrlString()) compute_node, software_release.getUrlString())
self.tic() self.tic()
...@@ -746,13 +760,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -746,13 +760,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(len(upgrade_decision2), 0) self.assertEqual(len(upgrade_decision2), 0)
def testComputeNode_checkAndCreateUpgradeDecision_ask_confirmation_with_exist(self): def testComputeNode_checkAndCreateUpgradeDecision_ask_confirmation_with_exist(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode(owner=person, compute_node, _ = self._makeComputeNode(project,
allocation_scope="open/personal") allocation_scope="open/personal")
compute_node.edit(upgrade_scope="ask_confirmation") compute_node.edit(upgrade_scope="ask_confirmation")
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._makeSoftwareRelease(software_product)
software_product.getRelativeUrl())
self._makeSoftwareInstallation( self._makeSoftwareInstallation(
compute_node, software_release.getUrlString()) compute_node, software_release.getUrlString())
self._requestSoftwareRelease(software_product.getRelativeUrl()) self._requestSoftwareRelease(software_product.getRelativeUrl())
...@@ -775,13 +788,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -775,13 +788,12 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
software_release3.getUrlString()) software_release3.getUrlString())
def testComputeNode_checkAndCreateUpgradeDecision_auto_with_exist(self): def testComputeNode_checkAndCreateUpgradeDecision_auto_with_exist(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode(owner=person, compute_node, _ = self._makeComputeNode(project,
allocation_scope="open") allocation_scope="open")
compute_node.edit(upgrade_scope="auto") compute_node.edit(upgrade_scope="auto")
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release = self._requestSoftwareRelease( software_release = self._makeSoftwareRelease(software_product)
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node, software_release.getUrlString()) self._makeSoftwareInstallation(compute_node, software_release.getUrlString())
self._requestSoftwareRelease(software_product.getRelativeUrl()) self._requestSoftwareRelease(software_product.getRelativeUrl())
self.tic() self.tic()
...@@ -1008,8 +1020,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -1008,8 +1020,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
"%s contains the wrong message" % redirect_url) "%s contains the wrong message" % redirect_url)
def testUpgradeDecision_isUpgradeFinished_compute_node(self): def testUpgradeDecision_isUpgradeFinished_compute_node(self):
compute_node, _ = self._makeComputeNode() project = self.addProject()
software_release = self._makeSoftwareRelease() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, compute_node]) upgrade_decision_line.setAggregateValueList([software_release, compute_node])
...@@ -1066,8 +1080,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -1066,8 +1080,10 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
upgrade_decision.getSimulationState(), requested_state)) upgrade_decision.getSimulationState(), requested_state))
def testUpgradeDecision_isUpgradeFinished_instance_tree(self): def testUpgradeDecision_isUpgradeFinished_instance_tree(self):
project = self.addProject()
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
software_release = self._makeSoftwareRelease() software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, upgrade_decision_line.setAggregateValueList([software_release,
...@@ -1086,11 +1102,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -1086,11 +1102,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["testUpgradeDecision_notify_compute_node"])') 'context.REQUEST["testUpgradeDecision_notify_compute_node"])')
def testUpgradeDecision_notify_compute_node(self): def testUpgradeDecision_notify_compute_node(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode() person = self._makePerson(project)
software_release = self._makeSoftwareRelease() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release.setAggregateValue(software_product) software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.edit(destination_decision_value=person) upgrade_decision.edit(destination_decision_value=person)
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -1146,11 +1162,11 @@ ${new_software_release_url}""", ...@@ -1146,11 +1162,11 @@ ${new_software_release_url}""",
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["testUpgradeDecision_notify_instance_tree"])') 'context.REQUEST["testUpgradeDecision_notify_instance_tree"])')
def testUpgradeDecision_notify_instance_tree(self): def testUpgradeDecision_notify_instance_tree(self):
person = self._makePerson() project = self.addProject()
person = self._makePerson(project)
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
software_release = self._makeSoftwareRelease() software_product = self._makeSoftwareProduct(project)
software_product = self._makeSoftwareProduct() software_release = self._makeSoftwareRelease(software_product)
software_release.setAggregateValue(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.edit(destination_decision_value=person) upgrade_decision.edit(destination_decision_value=person)
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -1211,11 +1227,11 @@ ${new_software_release_url}""", ...@@ -1211,11 +1227,11 @@ ${new_software_release_url}""",
@simulate('UpgradeDecision_isUpgradeFinished', @simulate('UpgradeDecision_isUpgradeFinished',
'', 'return 1') '', 'return 1')
def testUpgradeDecision_notifyDelivered_compute_node(self): def testUpgradeDecision_notifyDelivered_compute_node(self):
person = self._makePerson() project = self.addProject()
compute_node, _ = self._makeComputeNode() person = self._makePerson(project)
software_release = self._makeSoftwareRelease() compute_node, _ = self._makeComputeNode(project)
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release.setAggregateValue(software_product) software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.edit(destination_decision_value=person) upgrade_decision.edit(destination_decision_value=person)
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -1274,11 +1290,12 @@ ${new_software_release_url}""", ...@@ -1274,11 +1290,12 @@ ${new_software_release_url}""",
@simulate('UpgradeDecision_isUpgradeFinished', @simulate('UpgradeDecision_isUpgradeFinished',
'', 'return 1') '', 'return 1')
def testUpgradeDecision_notifyDelivered_instance_tree(self): def testUpgradeDecision_notifyDelivered_instance_tree(self):
person = self._makePerson() project = self.addProject()
person = self._makePerson(project)
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
software_release = self._makeSoftwareRelease() software_product = self._makeSoftwareProduct(project)
software_product = self._makeSoftwareProduct() software_release = self._makeSoftwareRelease(software_product)
software_release.setAggregateValue(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.edit(destination_decision_value=person) upgrade_decision.edit(destination_decision_value=person)
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -1333,7 +1350,9 @@ ${new_software_release_url}""", ...@@ -1333,7 +1350,9 @@ ${new_software_release_url}""",
self.assertEqual(event.getSimulationState(), "delivered") self.assertEqual(event.getSimulationState(), "delivered")
def testUpgradeDecisionLine_cancel_already_cancelled(self): def testUpgradeDecisionLine_cancel_already_cancelled(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.cancel(comment="Cancelled by the test") upgrade_decision.cancel(comment="Cancelled by the test")
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
...@@ -1346,8 +1365,10 @@ ${new_software_release_url}""", ...@@ -1346,8 +1365,10 @@ ${new_software_release_url}""",
self.assertEqual("Cancelled by the test", workflow_history_list[-1].comment) self.assertEqual("Cancelled by the test", workflow_history_list[-1].comment)
def testUpgradeDecisionLine_cancel_archived_software_release(self): def testUpgradeDecisionLine_cancel_archived_software_release(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release]) upgrade_decision_line.setAggregateValueList([software_release])
...@@ -1370,7 +1391,9 @@ ${new_software_release_url}""", ...@@ -1370,7 +1391,9 @@ ${new_software_release_url}""",
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_instance_tree"])') 'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_instance_tree"])')
def testUpgradeDecisionLine_cancel_destroyed_instance_tree(self): def testUpgradeDecisionLine_cancel_destroyed_instance_tree(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
instance_tree = self._makeFullInstanceTree(software_release.getUrlString()) instance_tree = self._makeFullInstanceTree(software_release.getUrlString())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
...@@ -1415,7 +1438,9 @@ ${new_software_release_url}""", ...@@ -1415,7 +1438,9 @@ ${new_software_release_url}""",
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_instance_tree"])') 'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_instance_tree"])')
def testUpgradeDecisionLine_cancel_destroyed_instance_tree_and_disabled_monitor(self): def testUpgradeDecisionLine_cancel_destroyed_instance_tree_and_disabled_monitor(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct(project)
software_release = self._makeSoftwareRelease(software_product)
instance_tree = self._makeFullInstanceTree(software_release.getUrlString()) instance_tree = self._makeFullInstanceTree(software_release.getUrlString())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
...@@ -1461,9 +1486,9 @@ ${new_software_release_url}""", ...@@ -1461,9 +1486,9 @@ ${new_software_release_url}""",
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr"])') 'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr"])')
def testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr(self): def testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr(self):
software_release = self._makeSoftwareRelease() project = self.addProject()
software_product = self._makeSoftwareProduct() software_product = self._makeSoftwareProduct(project)
software_release.setAggregateValue(software_product) software_release = self._makeSoftwareRelease(software_product)
instance_tree = self._makeFullInstanceTree(software_release.getUrlString()) instance_tree = self._makeFullInstanceTree(software_release.getUrlString())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
......
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