[Erp5-report] r43651 arnaud.fontaine - /erp5/trunk/products/ERP5Type/tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Feb 24 08:30:25 CET 2011
Author: arnaud.fontaine
Date: Thu Feb 24 08:30:25 2011
New Revision: 43651
URL: http://svn.erp5.org?rev=43651&view=rev
Log:
Add test to check for invalid TALES Expressions, namely syntax error
and invalid category in a DynamicCategoryProperty, but skip the test
for now as accessors generation through Utils does not deal with that
Modified:
erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
Modified: erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py?rev=43651&r1=43650&r2=43651&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] Thu Feb 24 08:30:25 2011
@@ -1002,10 +1002,9 @@ class TestZodbPropertySheet(ERP5TypeTest
def testAddEmptyProperty(self):
"""
- When users create properties in a PropertySheet, the property
- is first empty.
- Check that accessor generation can cope with such invalid
- properties
+ When users create properties in a PropertySheet, the property is
+ first empty. Check that accessor generation can cope with such
+ invalid properties
"""
property_sheet_tool = self.portal.portal_property_sheets
arrow = property_sheet_tool.Arrow
@@ -1049,15 +1048,57 @@ class TestZodbPropertySheet(ERP5TypeTest
except Exception:
self.fail("Creating an empty Constraint raises an error")
- # be really nasty, and test that code is still foolproof
- # (this None value should never appear in an expression... unless
- # the method has a mistake)
- dynamic_category.setCategoryExpression('python: ["foo", None, "region"]')
+ @skip("Skipped until per-document accessors generation is committed")
+ def testAddInvalidProperty(self):
+ """
+ Check that setting an invalid TALES Expression as a property
+ attribute value does not raise any error
+
+ XXX: For now, this test fails because the accessors generation
+ going through Utils does catch errors when evaluating TALES
+ Expression, but this will be addressed in per-property document
+ accessors generation
+ """
+ arrow = self.portal.portal_property_sheets.Arrow
+ person = self.portal.person_module.newContent(portal_type="Person")
+
+ # be really nasty, and test that code is still foolproof (this
+ # None value should never appear in an expression... unless the
+ # method has a mistake)
+ dynamic_category = arrow.newContent(
+ portal_type="Dynamic Category Property",
+ category_expression='python: ["foo", None, "region"]')
+
+ transaction.commit()
+ try:
+ person.newContent(portal_type="Career")
+ except Exception, e:
+ self.fail("Creating a Category Expression with None as one of the "\
+ "category ID raises an error")
+
+ # Action -> add Acquired Property
+ arrow.newContent(portal_type="Acquired Property",
+ acquisition_portal_type="python: ('foo', None)",
+ content_portal_type="python: ('goo', None)")
+ # a user is doing this, so commit after each request
+ transaction.commit()
+ try:
+ person.newContent(portal_type="Career")
+ except Exception:
+ self.fail("Creating an Acquired Property with invalid TALES expression "\
+ "raises an error")
+
+ # Check invalid syntax in TALES Expression, we check only for
+ # DynamicCategoryProperty because it's exactly the same function
+ # called for StandardProperty and AcquiredProperty, namely
+ # evaluateExpressionFromString
+ dynamic_category.setCategoryExpression('python: [')
transaction.commit()
try:
person.newContent(portal_type="Career")
except Exception:
- self.fail("Creating an invalid Category Expression raises an error")
+ self.fail("Creating a Category Expression with syntax error raises "\
+ "an error")
from Products.CMFCore.Expression import Expression
More information about the Erp5-report
mailing list