From cf5fbcfe8a4d90ae4bc6c111c1b35b484fbaab74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 28 Mar 2007 07:50:06 +0000 Subject: [PATCH] don't use 'if obj', it's a coding crime. Add test for Predicate_getMembershipCriterionCategoryList git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13733 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...ate_getMembershipCriterionCategoryList.xml | 2 +- product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- product/ERP5/tests/testPredicate.py | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml index 83f18f1f9e..3882d1c667 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml @@ -85,7 +85,7 @@ for item in mixed_list:\n if item_list == [[\'\', \'\']]:\n for fallback_category in base_category.getFallbackBaseCategoryList():\n fallback_category = ctool.restrictedTraverse(fallback_category, None)\n - if fallback_category:\n + if fallback_category is not None and fallback_category.objectIds():\n item_list = [(\'%s/%s\' % (item, x[0]), \'%s/%s\' % (item, x[1])) for x in\n fallback_category.getCategoryChildCompactLogicalPathItemList(base=1)]\n break\n diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index 4e66132b50..fefb598af8 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -282 \ No newline at end of file +284 \ No newline at end of file diff --git a/product/ERP5/tests/testPredicate.py b/product/ERP5/tests/testPredicate.py index 8df4cd07f8..eab099952d 100644 --- a/product/ERP5/tests/testPredicate.py +++ b/product/ERP5/tests/testPredicate.py @@ -378,6 +378,31 @@ class TestPredicates(ERP5TypeTestCase): self.assertEquals([True, False, True, False], calls) + def test_Predicate_getMembershipCriterionCategoryList(self): + # Predicate_getMembershipCriterionCategoryList is a script used to show the + # item list in Predicate_view/my_membership_criterion_category_list. + # When called on a predicate using a simple category (like region) as + # membership criterion base category, it will show for values the content + # of this category. + pred = self.createPredicate( + membership_criterion_base_category_list=['region'], ) + self.failUnless(('europe/western_europe', 'region/europe/western_europe') in + [tuple(x) for x in pred.Predicate_getMembershipCriterionCategoryList()], + pred.Predicate_getMembershipCriterionCategoryList(),) + + # If this category is empty, it will show values from fallback category, + # with the path they have when they are acquired + pred = self.createPredicate( + membership_criterion_base_category_list=['source_region'], ) + # note that the id of the actual base category is displayed in the first + # item too, for making it clear in the UI that it's the content of a + # category used for another base category. + self.failUnless(('source_region/europe/western_europe', + 'source_region/region/europe/western_europe') in + [tuple(x) for x in pred.Predicate_getMembershipCriterionCategoryList()], + pred.Predicate_getMembershipCriterionCategoryList(),) + + def test_PredicateFusion(self, quiet=QUIET, run=RUN_ALL_TESTS): """Test simple predicates fusion. New predicate act as a logical AND between predicates -- 2.30.9