Commit 87ab190b authored by Vincent Pelletier's avatar Vincent Pelletier

DomainTool: Raise when given unknown base categories.

Otherwise, some otherise-matching predicates may be excluded from the
search, and will not be applied.
parent df7d0a57
......@@ -172,6 +172,8 @@ class DomainTool(BaseTool):
category_list = []
extend = category_list.extend
for tested_base_category in tested_base_category_list:
if portal_categories.get(tested_base_category) is None:
raise ValueError('Unknown base category: %r' % (tested_base_category, ))
extend(getter(tested_base_category, base=1))
preferred_predicate_category_list = portal.portal_preferences.getPreferredPredicateCategoryList()
......
......@@ -437,6 +437,15 @@ class TestDomainTool(TestPredicateMixIn):
# resource is not in preferred predicate category list, so only inner join is used
assertUsesLeftJoinAndPredicateItemsMatchingOrderLineEqual(False, [supply1_line1], tested_base_category_list=['source_section', 'destination_section', 'price_currency', 'resource'])
# unknown base category ids cause an exception, so typos are detected
self.assertRaises(
ValueError,
searchPredicateList,
context=order_line,
portal_type='Sale Supply Line',
tested_base_category_list=['BOOO'],
)
def test_searchPredicateInvalidCategories(self):
predicate = self.portal.sale_supply_module.newContent(
portal_type='Sale Supply')
......
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