Commit f19b3a4b authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_upgrader: add a test for the new renaming feature

parent 827e354b
......@@ -434,6 +434,58 @@ class TestUpgrader(ERP5TypeTestCase):
self.fail("checkConsistency should not raise exception."
"It means that one Business Template was not found in repositories")
def stepCreateOrganisationWithActivity(self, sequence=None):
new_organisation = self.portal.organisation_module.newContent(
portal_type="Organisation",
title="Active Organisation",
activity="education")
self.tic()
self.assertEqual(new_organisation.getCategoriesList(),
['activity/education'])
sequence.set('organisation', new_organisation)
def stepCreateCustomUpgradeCategoryList(self, sequence=None):
portal = self.portal
skin_folder = portal.portal_skins.custom
script_id = "Base_getUpgradeCategoryNameList"
skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(script_id)
custom_script = getattr(skin_folder, script_id)
script_body = "return (('activity', 'business_core'),)"
custom_script.ZPythonScript_edit('', script_body)
def stepRemoveCustomUpgradeCategoryList(self, sequence=None):
custom_folder = self.portal.portal_skins.custom
custom_folder.manage_delObjects("Base_getUpgradeCategoryNameList")
def stepRenameCategoryActivityToBusinessCore(self, sequence=None):
"""Renames the category 'activity' to 'business_core'"""
self.portal.portal_categories.activity.edit(
id="business_core",
title="Business Core")
def stepUpdateOrganisationPropertySheetManually(self, sequence=None):
"""
Changes the category property Activity of an Organisation to Business Core.
This step is made manually in the step, but in a real case the old property
sheet would be replaced by a new one saved in a business template to upgrade
"""
activity = self.portal.portal_property_sheets.Organisation.activity_category
activity.edit(id="business_core_category",
title= "business_core",
reference="business_core")
def stepCheckOrganisationObjectUpdated(self, sequence=None):
self.assertEqual(sequence.get('organisation').getCategoriesList(),
['business_core/education'])
def stepCheckPostUpgradeCategoryName(self, sequence=None):
alarm = getattr(self.portal.portal_alarms, 'upgrader_check_post_upgrade')
active_process = alarm.getLastActiveProcess()
detail_list = active_process.getResultList()[0].detail
message = 'Portal Type Organisation still contains the category activity'
self.assertTrue(message in detail_list, detail_list)
self.assertTrue(detail_list.count(message), 1)
def test_workflow_chain_constraint(self):
""" Check if Workflow chains is broken, it can be detected and fixed after
upgrade"""
......@@ -633,3 +685,27 @@ class TestUpgrader(ERP5TypeTestCase):
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_rename_category(self):
"""Check that the renaming category feature correctly updates objects"""
self.portal.portal_categories.Folder_reindexAll()
self.tic()
sequence_list = SequenceList()
sequence_string = """
stepCreateOrganisationWithActivity
stepCreateCustomUpgradeCategoryList
stepRenameCategoryActivityToBusinessCore
stepUpdateOrganisationPropertySheetManually
stepTic
stepActiveSensePreUpgradeAlarm
stepActiveSensePostUpgradeAlarm
stepTic
stepRunUpgrader
stepTic
stepRunPostUpgrade
stepTic
stepCheckOrganisationObjectUpdated
stepRemoveCustomUpgradeCategoryList
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
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