Commit 7e187cf0 authored by Vincent Pelletier's avatar Vincent Pelletier

testCMFCategory: Extend test_09_GetCategoryParentUidList

parent 0480dd10
......@@ -317,9 +317,15 @@ class TestCMFCategory(ERP5TypeTestCase):
portal_categories = self.getCategoriesTool()
getCategoryParentUidList = portal_categories.getCategoryParentUidList
basecat = portal_categories.newContent(portal_type='Base Category', id='basecat')
basecat2 = portal_categories.newContent(portal_type='Base Category', id='basecat2')
cat1 = basecat.newContent(portal_type='Category', id='cat1')
cat2 = cat1.newContent(portal_type='Category', id='cat2')
cat22 = cat2.newContent(portal_type='Category', id='cat2')
cat3 = cat1.newContent(portal_type='Category', id='cat3')
module = self.getPersonModule()
person = module.newContent(portal_type='Person')
address = person.newContent(portal_type='Address')
# Non-strict, implicit base category
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(),
......@@ -330,6 +336,83 @@ class TestCMFCategory(ERP5TypeTestCase):
(basecat.getUid(), basecat.getUid(), 0),
],
)
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=cat22.getRelativeUrl(),
),
[
(cat22.getUid(), basecat.getUid(), 1),
(cat2.getUid(), basecat.getUid(), 0),
(cat1.getUid(), basecat.getUid(), 0),
(basecat.getUid(), basecat.getUid(), 0),
],
)
# Non-canonical path
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=cat2.getRelativeUrl() + '/' + cat3.getId(),
),
[
(cat3.getUid(), basecat.getUid(), 1),
(cat2.getUid(), basecat.getUid(), 0),
(cat1.getUid(), basecat.getUid(), 0),
(basecat.getUid(), basecat.getUid(), 0),
],
)
# Strict, implicit base category
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(),
strict=True,
),
[
(cat2.getUid(), basecat.getUid(), 1),
],
)
# Non-strict, explicit base category
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(),
base_category=basecat2.getId(),
),
[
(cat2.getUid(), basecat2.getUid(), 1),
(cat1.getUid(), basecat2.getUid(), 0),
(basecat.getUid(), basecat2.getUid(), 0),
],
)
# Strict, explicit base category
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(),
base_category=basecat2.getId(),
strict=True,
),
[
(cat2.getUid(), basecat2.getUid(), 1),
],
)
# Non-strict with a non-category relation: only strict relation uid.
# Note: not providing base_category is undefined behaviour.
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=person.getRelativeUrl(),
base_category=basecat.getId(),
),
[
(person.getUid(), basecat.getUid(), 1),
],
)
# ... even on a subobject
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=address.getRelativeUrl(),
base_category=basecat.getId(),
),
[
(address.getUid(), basecat.getUid(), 1),
],
)
def test_10_FallBackBaseCategory(self):
# Test if we can use an alternative base category
......
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