Commit 54351d51 authored by Jérome Perrin's avatar Jérome Perrin

Implement support for strict_membership in getCategoryMemberValueList. from Guy Oswald Obama



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10030 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5db84329
......@@ -1380,9 +1380,12 @@ class CategoryTool( UniqueObject, Folder, Base ):
else:
raise CategoryError('getCategoryMemberValueList must know the base category')
strict_membership = kw.get('strict_membership', kw.get('strict', 0))
if strict_membership:
catalog_search = self.portal_catalog(portal_type = portal_type,
selection_report = DomainSelection(domain_dict = {base_category:context}))
else:
catalog_search = self.portal_catalog(portal_type = portal_type,
# TODO: make it work in catalog tool
# category_strict_membership = strict_membership,
selection_domain = DomainSelection(domain_dict = {base_category:context}))
return catalog_search
......
......@@ -611,6 +611,49 @@ class TestCMFCategory(ERP5TypeTestCase):
region_value.setCategoryList(category_list)
self.assertEqual(category_list, region_value.getCategoryList())
def test_19_CategoryMemberValueList(self, quiet=0, run=run_all_test):
"""Test strict_membership parameter to Category Member Value List """
if not run : return
if not quiet:
message = 'Test strict_membership and Category Member Value List'
ZopeTestCase._print('\n '+message)
LOG('Testing... ',0,message)
portal_categories = self.getCategoryTool()
organisation = self.getOrganisationModule().newContent(
portal_type='Organisation', region='west/france')
get_transaction().commit()
self.tic()
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west.france,
base_category='region',
strict_membership=0,
portal_type='Organisation')], [organisation])
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west.france,
base_category='region',
strict_membership=1,
portal_type='Organisation')], [organisation])
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west,
base_category='region',
strict_membership=0,
portal_type='Organisation')], [organisation])
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west,
base_category='region',
strict_membership=1,
portal_type='Organisation')], [])
if __name__ == '__main__':
framework()
else:
......
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