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

Merge branch 'master' into erp5_workflow

parents f6d59571 9d08cb2c
<property_sheet_list>
<portal_type id="Template Tool">
<item>TemplateToolBusinessTemplateInstallationConstraint</item>
<item>TemplateToolTableExistenceConstraint</item>
<item>TemplateToolTableConsistencyConstraint</item>
<item>TemplateToolWorkflowChainConsistencyConstraint</item>
</portal_type>
</property_sheet_list>
\ No newline at end of file
......@@ -32,7 +32,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateToolTableExistenceConstraint</string> </value>
<value> <string>TemplateToolTableConsistencyConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -34,7 +34,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>table_existence_constraint</string> </value>
<value> <string>table_consistency_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -42,7 +42,7 @@
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>TemplateTool_checkTableExistence</string> </value>
<value> <string>TemplateTool_checkTableConsistency</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -57,7 +57,7 @@
a old business template without updating it and without removing it\n
"""\n
\n
return (\'erp5_base\',), []\n
return (\'erp5_base\',), ["erp5_upgrader"]\n
</string> </value>
</item>
<item>
......
......@@ -54,6 +54,7 @@
\n
template_tool = context.getPortalObject().portal_templates\n
return template_tool.upgradeSite(bt5_list,\n
delete_orphaned=True,\n
keep_bt5_id_set=keep_bt5_id_set,\n
dry_run=(not fixit))\n
</string> </value>
......
......@@ -51,25 +51,16 @@
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Check for some table existence according to the create table list.\n
If `fixit` is True, then it uses the associated sql_method to create it.\n
Check for some table consistency according to the create table list.\n
If `fixit` is True, then it will create/drop table or alter existing tables\n
"""\n
create_table_list = [\n
# ("category", "z_create_category"), # example\n
("catalog_full_text", "z_create_catalog_fulltext"),\n
]\n
sql_catalog = context.portal_catalog.getSQLCatalog()\n
table_list = [r[0] for r in sql_catalog.z_show_tables(table="not needed so far")]\n
report_list = []\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
portal = context.getPortalObject()\n
show_source = not(fixit)\n
sql_src = portal.portal_catalog.upgradeSchema(src__=show_source)\n
result = []\n
if sql_src:\n
result.append(sql_src)\n
return result\n
</string> </value>
</item>
<item>
......@@ -78,7 +69,7 @@ return report_list\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateTool_checkTableExistence</string> </value>
<value> <string>TemplateTool_checkTableConsistency</string> </value>
</item>
</dictionary>
</pickle>
......
Template Tool | TemplateToolBusinessTemplateInstallationConstraint
Template Tool | TemplateToolTableExistenceConstraint
Template Tool | TemplateToolTableConsistencyConstraint
Template Tool | TemplateToolWorkflowChainConsistencyConstraint
\ No newline at end of file
TemplateToolBusinessTemplateInstallationConstraint
TemplateToolWorkflowChainConsistencyConstraint
TemplateToolTableExistenceConstraint
\ No newline at end of file
TemplateToolTableConsistencyConstraint
\ No newline at end of file
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return (\'erp5_web\',), []\n
<value> <string>return (\'erp5_web\',), ["erp5_upgrader", "erp5_upgrader_test"]\n
</string> </value>
</item>
<item>
......
......@@ -170,7 +170,7 @@ class TestXHTMLMixin(ERP5TypeTestCase):
skins_tool, obj_metatypes=['File','DTML Method','DTML Document'], search_sub=1):
is_required_check_path = True
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'):
for ignore_bt_name in ignore_bts:
if script_path.startswith(ignore_bt_name):
......
......@@ -28,6 +28,7 @@
##############################################################################
import unittest
from unittest import expectedFailure
from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase
from AccessControl.SecurityManagement import newSecurityManager
......@@ -65,6 +66,9 @@ class TestConstraint(PropertySheetTestCase):
self.portal = self.getPortal()
self.category_tool = self.getCategoryTool()
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):
self.login()
......@@ -72,6 +76,11 @@ class TestConstraint(PropertySheetTestCase):
module = self.portal.organisation_module
module.manage_delObjects(list(module.objectIds()))
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):
"""
......@@ -110,10 +119,12 @@ class TestConstraint(PropertySheetTestCase):
module = portal.getDefaultModule(self.object_portal_type)
object = module.newContent(portal_type=self.object_portal_type)
group1 = object.portal_categories.restrictedTraverse('group/testGroup1')
sequence.edit(
object=object,
group=group1,
)
if sequence:
sequence.edit(
object=object,
group=group1,
)
return object
def stepSetObjectGroup(self, sequence=None,
sequence_list=None, **kw):
......@@ -1581,6 +1592,33 @@ class TestConstraint(PropertySheetTestCase):
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():
suite = unittest.TestSuite()
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