Commit 0480dd10 authored by Vincent Pelletier's avatar Vincent Pelletier

testCMFCategory: Simplify test_09_GetCategoryParentUidList

Drop overly descriptive comments.
Simplify code.
Fix coding style.
parent a2c7ef15
......@@ -314,27 +314,22 @@ class TestCMFCategory(ERP5TypeTestCase):
def test_09_GetCategoryParentUidList(self):
# Test if an infinite loop of the acquisition for a single value is working
# WARNING: getCategoryParentUidList does not provide a sorted result
portal_categories = self.getCategoriesTool()
# Create a base category basecat
#portal_categories.manage_addProduct['ERP5'].addBaseCategory('basecat')
portal_categories.newContent(portal_type='Base Category',id='basecat')
# Create a category cat1 at basecate
portal_categories.basecat.newContent(id='cat1',portal_type='Category')
basecat = portal_categories.basecat
cat1 = portal_categories.basecat.cat1
# Create a category cat2 at cat1
portal_categories.basecat.cat1.newContent(portal_type='Category',id='cat2')
cat2 = portal_categories.basecat.cat1.cat2
cat2.newContent(id='cat2',portal_type='Category')
# Compare result after sorting it
parent_uid_list = [(cat2.getUid(), basecat.getUid(), 1),
(cat1.getUid(), basecat.getUid(), 0),
(basecat.getUid(), basecat.getUid(), 0)]
parent_uid_list.sort()
parent_uid_list2 = cat2.getCategoryParentUidList(relative_url = cat2.getRelativeUrl())
parent_uid_list2.sort()
self.assertEqual(parent_uid_list2, parent_uid_list)
getCategoryParentUidList = portal_categories.getCategoryParentUidList
basecat = portal_categories.newContent(portal_type='Base Category', id='basecat')
cat1 = basecat.newContent(portal_type='Category', id='cat1')
cat2 = cat1.newContent(portal_type='Category', id='cat2')
cat22 = cat2.newContent(portal_type='Category', id='cat2')
self.assertItemsEqual(
getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(),
),
[
(cat2.getUid(), basecat.getUid(), 1),
(cat1.getUid(), basecat.getUid(), 0),
(basecat.getUid(), basecat.getUid(), 0),
],
)
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