Commit d7d81c20 authored by wenjie.zheng's avatar wenjie.zheng

Merge branch 'master' into erp5_workflow

parents f6d59571 9d08cb2c
<property_sheet_list> <property_sheet_list>
<portal_type id="Template Tool"> <portal_type id="Template Tool">
<item>TemplateToolBusinessTemplateInstallationConstraint</item> <item>TemplateToolBusinessTemplateInstallationConstraint</item>
<item>TemplateToolTableExistenceConstraint</item> <item>TemplateToolTableConsistencyConstraint</item>
<item>TemplateToolWorkflowChainConsistencyConstraint</item> <item>TemplateToolWorkflowChainConsistencyConstraint</item>
</portal_type> </portal_type>
</property_sheet_list> </property_sheet_list>
\ No newline at end of file
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>TemplateToolTableExistenceConstraint</string> </value> <value> <string>TemplateToolTableConsistencyConstraint</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>table_existence_constraint</string> </value> <value> <string>table_consistency_constraint</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</item> </item>
<item> <item>
<key> <string>script_id</string> </key> <key> <string>script_id</string> </key>
<value> <string>TemplateTool_checkTableExistence</string> </value> <value> <string>TemplateTool_checkTableConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
a old business template without updating it and without removing it\n a old business template without updating it and without removing it\n
"""\n """\n
\n \n
return (\'erp5_base\',), []\n return (\'erp5_base\',), ["erp5_upgrader"]\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
\n \n
template_tool = context.getPortalObject().portal_templates\n template_tool = context.getPortalObject().portal_templates\n
return template_tool.upgradeSite(bt5_list,\n return template_tool.upgradeSite(bt5_list,\n
delete_orphaned=True,\n
keep_bt5_id_set=keep_bt5_id_set,\n keep_bt5_id_set=keep_bt5_id_set,\n
dry_run=(not fixit))\n dry_run=(not fixit))\n
</string> </value> </string> </value>
......
...@@ -51,25 +51,16 @@ ...@@ -51,25 +51,16 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Check for some table existence according to the create table list.\n Check for some table consistency according to the create table list.\n
If `fixit` is True, then it uses the associated sql_method to create it.\n If `fixit` is True, then it will create/drop table or alter existing tables\n
"""\n """\n
create_table_list = [\n portal = context.getPortalObject()\n
# ("category", "z_create_category"), # example\n show_source = not(fixit)\n
("catalog_full_text", "z_create_catalog_fulltext"),\n sql_src = portal.portal_catalog.upgradeSchema(src__=show_source)\n
]\n result = []\n
sql_catalog = context.portal_catalog.getSQLCatalog()\n if sql_src:\n
table_list = [r[0] for r in sql_catalog.z_show_tables(table="not needed so far")]\n result.append(sql_src)\n
report_list = []\n return result\n
for create_table_information in create_table_list:\n
if not callable(getattr(sql_catalog, create_table_information[1], None)):\n
continue\n
if create_table_information[0] not in table_list:\n
if fixit:\n
getattr(sql_catalog, create_table_information[1], None)()\n
else:\n
report_list.append("Table `%s` not created (%s)" % create_table_information)\n
return report_list\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -78,7 +69,7 @@ return report_list\n ...@@ -78,7 +69,7 @@ return report_list\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>TemplateTool_checkTableExistence</string> </value> <value> <string>TemplateTool_checkTableConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
Template Tool | TemplateToolBusinessTemplateInstallationConstraint Template Tool | TemplateToolBusinessTemplateInstallationConstraint
Template Tool | TemplateToolTableExistenceConstraint Template Tool | TemplateToolTableConsistencyConstraint
Template Tool | TemplateToolWorkflowChainConsistencyConstraint Template Tool | TemplateToolWorkflowChainConsistencyConstraint
\ No newline at end of file
TemplateToolBusinessTemplateInstallationConstraint TemplateToolBusinessTemplateInstallationConstraint
TemplateToolWorkflowChainConsistencyConstraint TemplateToolWorkflowChainConsistencyConstraint
TemplateToolTableExistenceConstraint TemplateToolTableConsistencyConstraint
\ No newline at end of file \ No newline at end of file
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>return (\'erp5_web\',), []\n <value> <string>return (\'erp5_web\',), ["erp5_upgrader", "erp5_upgrader_test"]\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -170,7 +170,7 @@ class TestXHTMLMixin(ERP5TypeTestCase): ...@@ -170,7 +170,7 @@ class TestXHTMLMixin(ERP5TypeTestCase):
skins_tool, obj_metatypes=['File','DTML Method','DTML Document'], search_sub=1): skins_tool, obj_metatypes=['File','DTML Method','DTML Document'], search_sub=1):
is_required_check_path = True is_required_check_path = True
ignore_bts = ['erp5_jquery','erp5_fckeditor','erp5_xinha_editor', ignore_bts = ['erp5_jquery','erp5_fckeditor','erp5_xinha_editor',
'erp5_jquery_ui', 'erp5_ace_editor'] 'erp5_jquery_ui', 'erp5_ace_editor', 'erp5_code_mirror']
if script_path.endswith('.js'): if script_path.endswith('.js'):
for ignore_bt_name in ignore_bts: for ignore_bt_name in ignore_bts:
if script_path.startswith(ignore_bt_name): if script_path.startswith(ignore_bt_name):
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from unittest import expectedFailure
from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -65,6 +66,9 @@ class TestConstraint(PropertySheetTestCase): ...@@ -65,6 +66,9 @@ class TestConstraint(PropertySheetTestCase):
self.portal = self.getPortal() self.portal = self.getPortal()
self.category_tool = self.getCategoryTool() self.category_tool = self.getCategoryTool()
self.createCategories() self.createCategories()
portal_property_sheets = self.portal.portal_property_sheets
if getattr(portal_property_sheets, "test_constraint", None) != None:
portal_property_sheets.manage_delObjects(ids=["test_constraint"])
def beforeTearDown(self): def beforeTearDown(self):
self.login() self.login()
...@@ -72,6 +76,11 @@ class TestConstraint(PropertySheetTestCase): ...@@ -72,6 +76,11 @@ class TestConstraint(PropertySheetTestCase):
module = self.portal.organisation_module module = self.portal.organisation_module
module.manage_delObjects(list(module.objectIds())) module.manage_delObjects(list(module.objectIds()))
super(TestConstraint, self).beforeTearDown() super(TestConstraint, self).beforeTearDown()
portal_type = self.portal.portal_types[self.object_portal_type]
if "TestConstraint" in portal_type.getTypePropertySheetList():
portal_type.setTypePropertySheetList(
[x for x in portal_type.getTypePropertySheetList() \
if x != "TestConstraint"])
def createCategories(self): def createCategories(self):
""" """
...@@ -110,10 +119,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -110,10 +119,12 @@ class TestConstraint(PropertySheetTestCase):
module = portal.getDefaultModule(self.object_portal_type) module = portal.getDefaultModule(self.object_portal_type)
object = module.newContent(portal_type=self.object_portal_type) object = module.newContent(portal_type=self.object_portal_type)
group1 = object.portal_categories.restrictedTraverse('group/testGroup1') group1 = object.portal_categories.restrictedTraverse('group/testGroup1')
if sequence:
sequence.edit( sequence.edit(
object=object, object=object,
group=group1, group=group1,
) )
return object
def stepSetObjectGroup(self, sequence=None, def stepSetObjectGroup(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -1581,6 +1592,33 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1581,6 +1592,33 @@ class TestConstraint(PropertySheetTestCase):
sequence_list.play(self) sequence_list.play(self)
def createConstraintThatMustBeCalledOnce(self):
"""
Create a default allowing the check if they are called once
"""
property_sheet = self.portal.portal_property_sheets.newContent(
id="TestConstraint", title="Test Constraint")
constraint = property_sheet.newContent(portal_type="TALES Constraint",
id="check_title_constraint",
expression="python: object.setTitle(object.getTitle() + 'a')")
portal_type = self.portal.portal_types[self.object_portal_type]
if "TestConstraint" not in portal_type.getTypePropertySheetList():
portal_type.setTypePropertySheetList(
portal_type.getTypePropertySheetList() + ["TestConstraint"])
# Expected failure until checkConsistency is reviewed to not execute
# twice constraints
@expectedFailure
def test_09_CheckConstraintAreCalledOnce(self):
"""
Make sure we call only one time a constraint in a particular object
"""
self.createConstraintThatMustBeCalledOnce()
document = self.stepCreateObject()
document.setTitle("Foo")
document.checkConsistency()
self.assertEqual("Fooa", document.getTitle())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestConstraint)) suite.addTest(unittest.makeSuite(TestConstraint))
......
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