Commit 79860c6a authored by Jérome Perrin's avatar Jérome Perrin

implement testers for category accessors


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21439 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a14e9b57
......@@ -238,4 +238,9 @@ class ItemListGetter(BaseGetter):
psyco.bind(__call__)
# And Tester ???
class Tester(ListGetter):
"""Tests if the category is set.
"""
def __call__(self, instance, *args, **kw):
return not not ListGetter.__call__(self, instance, *args, **kw)
......@@ -1859,6 +1859,11 @@ def createCategoryAccessors(property_holder, id,
if not hasattr(property_holder, accessor_name):
property_holder.registerAccessor(accessor_name, id, Category.DefaultGetter, ())
accessor_name = 'has' + UpperCase(id)
if not hasattr(property_holder, accessor_name):
property_holder.registerAccessor(accessor_name, id, Category.Tester, ())
property_holder.declareProtected(read_permission, accessor_name)
setter_name = 'set' + UpperCase(id)
if not hasattr(property_holder, setter_name):
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
......
......@@ -1793,6 +1793,13 @@ class TestPropertySheet:
foo.setRegionValueSet([gamma],
checked_permission=checked_permission)
self.assertSameSet([beta_path, gamma_path], foo.getRegionList())
# check hasCategory accessors
foo.setRegionValue(None)
self.assertEquals(None, foo.getRegion())
self.assertFalse(foo.hasRegion())
foo.setRegionValue(beta)
self.assertTrue(foo.hasRegion())
def test_category_accessor_to_unaccessible_documents(self):
# Category Accessors raises Unauthorized when you try to access objects
......
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