Commit 87bda88d authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Add CatalogToolMigrationConstraint property sheet to erp5_upgrader bt5

And define the mentioned property sheet on Template Tool portal type. This is
necessary as while running the post_upgrade constaint 'migrate_catalog_constaint',
the script will run only if the portal_type it is defined on is indexed in the
catalog. But if we define it on 'Catalog Tool' portal type, it won't be called
as it can't be indexed before migration, so it is better to define on 'Template Tool'.

If needed, we can change the name of the property sheet to honor naming
conventions. Also, it makes more sense to have migration script in portal
skin 'erp5_upgrader' as it is also a part of upgrading erp5.

** Add test for migration of catalog via portal_alarm

** Also, update the other tests where it was taken for granted that
there are no constraint for 'post_upgrade', as now we have added
an extra post_upgrade constraint in erp5_upgrader bt5.
parent dd51053f
<property_sheet_list>
<portal_type id="Template Tool">
<item>CatalogToolMigrationConstraint</item>
<item>TemplateToolBusinessTemplateInstallationConstraint</item>
<item>TemplateToolCategoryNameConstraint</item>
<item>TemplateToolTableConsistencyConstraint</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CatalogToolMigrationConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>migrate_catalog_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>CatalogTool_migrateCatalog</string> </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>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# Migrate CMF portal_catalog to ERP5 portal_catalog
error_list = []
portal = context.getPortalObject()
if not portal.portal_catalog.meta_type == 'Catalog Tool':
error_list.append('Solve the alarm if you want ot migrate your Catalog(Tool)')
if fixit:
portal.migrateSQLCatalogToERP5Catalog()
return error_list
<?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>_params</string> </key>
<value> <string>fixit=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CatalogTool_migrateCatalog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -80,6 +80,22 @@ class TestUpgrader(ERP5TypeTestCase):
self.portal.portal_caches.clearCache(
cache_factory_list=('erp5_content_medium',))
def stepCheckCMFCatalog(self, sequence=None):
portal = self.portal
template_tool = portal.portal_templates
bt5_title_list = template_tool.getInstalledBusinessTemplateTitleList()
self.assertIn('erp5_upgrader', bt5_title_list)
portal_catalog = portal.portal_catalog
# Test if the portal_catalog if the old CMF Catalog one
self.assertEqual(portal_catalog.meta_type, 'ERP5 Catalog')
def stepCheckERP5Catalog(self, sequence=None):
portal = self.portal
portal_catalog = portal.portal_catalog
self.assertEqual(portal_catalog.meta_type, 'Catalog Tool')
catalog = portal_catalog.getERP5Catalog()
self.assertEqual(catalog.meta_type, 'ERP5 Catalog')
def stepCreatePropertySheetToValidateOrganisation(self, sequence=None):
portal = self.portal
skin_folder = portal.portal_skins.custom
......@@ -502,6 +518,24 @@ class TestUpgrader(ERP5TypeTestCase):
self.assertTrue(message in detail_list, detail_list)
self.assertTrue(detail_list.count(message), 1)
def test_catalog_migration(self):
"""Check if calling migration script via portal_alarm migrates
portal_catalog
"""
sequence_list = SequenceList()
sequence_string = """
stepCheckCMFCatalog
stepCheckFullUpgradeRequired
stepRunFullUpgrader
stepTic
stepCheckPostUpgradeRequired
stepRunPostUpgrade
stepTic
stepCheckERP5Catalog
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_workflow_chain_constraint(self):
""" Check if Workflow chains is broken, it can be detected and fixed after
upgrade"""
......@@ -516,7 +550,6 @@ class TestUpgrader(ERP5TypeTestCase):
stepSetConstraintInTemplateToolPortalType
stepActiveSensePostUpgradeAlarm
stepTic
stepCheckPostUpgradeEmptyConstraintList
stepSetDefaultWorkflowChainToPreference
stepActiveSensePostUpgradeAlarm
stepTic
......@@ -587,7 +620,6 @@ class TestUpgrader(ERP5TypeTestCase):
stepSetConstraintInPersonModulePortalType
stepTic
stepCheckUpgradeRequired
stepCheckPostUpgradeNotRequired
stepCreatePerson
stepValidatePerson
stepTic
......
......@@ -45,20 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>R: 33, 0: Too many ancestors (9/7) (too-many-ancestors)</string>
<string>W: 59,64: Unused argument \'sequence\' (unused-argument)</string>
<string>W: 76,42: Unused argument \'sequence\' (unused-argument)</string>
<string>W: 89,48: Unused argument \'sequence\' (unused-argument)</string>
<string>W:104,53: Unused argument \'sequence\' (unused-argument)</string>
<string>W:109,51: Unused argument \'sequence\' (unused-argument)</string>
<string>W:112,52: Unused argument \'sequence\' (unused-argument)</string>
<string>W:115,56: Unused argument \'sequence\' (unused-argument)</string>
<string>W:122,54: Unused argument \'sequence\' (unused-argument)</string>
<string>W:140,54: Unused argument \'sequence\' (unused-argument)</string>
<string>W:147,54: Unused argument \'sequence\' (unused-argument)</string>
<string>R: 33, 0: Too many public methods (136/20) (too-many-public-methods)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
Template Tool | CatalogToolMigrationConstraint
Template Tool | TemplateToolBusinessTemplateInstallationConstraint
Template Tool | TemplateToolCategoryNameConstraint
Template Tool | TemplateToolTableConsistencyConstraint
......
TemplateToolBusinessTemplateInstallationConstraint
TemplateToolCategoryNameConstraint
TemplateToolTableConsistencyConstraint
TemplateToolWorkflowChainConsistencyConstraint
\ No newline at end of file
TemplateToolWorkflowChainConsistencyConstraint
CatalogToolMigrationConstraint
\ 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