Commit 4a6fae01 authored by Vivien Alger's avatar Vivien Alger

Mass upgrade: second review changes

parent 8f2dbd98
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return [x for x in context.Base_getRelatedObjectList(portal_type=\'Software Release\') if x.SoftwareRelease_getUsableComputerList() != []]\n
<value> <string>return [x for x in context.Base_getRelatedObjectList(portal_type=\'Software Release\') if context.portal_catalog(portal_type=\'Software Installation\', slap_state=\'start_requested\', url_string=x.getUrlString(), limit=1)]\n
</string> </value>
</item>
<item>
......@@ -59,7 +59,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareProduct_getInstalledSoftwareReleases</string> </value>
<value> <string>SoftwareProduct_getInstalledSoftwareReleaseList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -70,7 +70,7 @@ for parameters in listbox:\n
if comp_reference_list != []:\n
for comp_reference in comp_reference_list:\n
comp = portal.portal_catalog.getResultValue(portal_type = \'Computer\', reference = comp_reference)\n
if new_sr_url not in portal.portal_catalog.getResultValue(portal_type=\'Software Installation\', aggregate_related_value=comp.getRelativeUrl()):\n
if new_sr_url not in portal.portal_catalog.getResultValue(portal_type=\'Software Installation\', default_aggregate_related_value=comp.getRelativeUrl()):\n
message_list.append("Software Release %s not installed on %s." % (new_sr_document.getTitle(), comp_reference))\n
else:\n
message_list.append("No computers selected for upgrade from %s to %s" % (old_sr_document.getUrlString(), new_sr_url))\n
......
......@@ -80,10 +80,6 @@
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>usage</string>
<string>Usage</string>
</tuple>
<tuple>
<string>title</string>
<string>Software Release</string>
......@@ -165,7 +161,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>SoftwareProduct_getInstalledSoftwareReleases</string> </value>
<value> <string>SoftwareProduct_getInstalledSoftwareReleaseList</string> </value>
</item>
</dictionary>
</pickle>
......
<?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>return context.portal_catalog.countResults(portal_type=(\'Software Instance\',\'Slave Instance\'), url_string=context.getUrlString(), slap_state=[\'start_requested\',\'stop_requested\'])[0][0]\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareRelease_getUsage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -64,7 +64,6 @@ class TestSlapOSMassUpgrade(testSlapOSMixin):
return computer
def _makeComputerPartitions(self,computer):
for i in range(1, 5):
id_ = 'partition%s' % (i, )
......@@ -100,6 +99,21 @@ class TestSlapOSMassUpgrade(testSlapOSMixin):
return software_release
def _makeSoftwareInstallation(self, new_id, computer, software_release_url):
software_installation = self.portal\
.software_installation_module.template_software_installation\
.Base_createCloneDocument(batch_mode=1)
software_installation.edit(
url_string=software_release_url,
aggregate=computer.getRelativeUrl(),
reference='TESTSOFTINSTS-%s' % new_id,
title='Start requested for %s' % computer.getUid()
)
software_installation.validate()
software_installation.requestStart()
return software_installation
def _makeHostingSubscription(self, new_id):
hosting_subscription = self.portal\
.hosting_subscription_module.template_hosting_subscription\
......@@ -125,19 +139,32 @@ class TestSlapOSMassUpgrade(testSlapOSMixin):
)
hosting_subscription.requestStart(**kw)
hosting_subscription.requestInstance(**kw)
def test_SoftwareRelease_getUsage_no_instance(self):
software_release = self._makeSoftwareRelease(self.new_id)
self.assertEqual(0,software_release.SoftwareRelease_getUsage())
def test_SoftwareRelease_getUsage_with_instance(self):
def test_SoftwareProduct_getInstalledSoftwareReleaseList(self):
computer = self._makeComputer(self.new_id)
software_product = self._makeSoftwareProduct(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
hosting_subscription = self._makeHostingSubscription(self.new_id)
self._makeSoftwareInstance(hosting_subscription,
software_release.edit(aggregate_value = software_product.getRelativeUrl())
self._makeSoftwareInstallation(self.new_id, computer,
software_release.getUrlString())
self.tic()
self.assertEqual(1,software_release.SoftwareRelease_getUsage())
self.assertEqual(
len(software_product.SoftwareProduct_getInstalledSoftwareReleaseList()),
1
)
def test_SoftwareProduct_getInstalledSoftwareReleaseList_no_installation(self):
software_product = self._makeSoftwareProduct(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
software_release.edit(aggregate_value = software_product.getRelativeUrl())
self.tic()
self.assertEqual(
len(software_product.SoftwareProduct_getInstalledSoftwareReleaseList()),
0
)
def test_ComputerPartition_changeHostingSubscriptionSoftwareRelease(self):
computer = self._makeComputer(self.new_id)
self._makeComputerPartitions(computer)
......
9
\ No newline at end of file
10
\ 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