Commit 8fb0a9d6 authored by Jérome Perrin's avatar Jérome Perrin

testCMFCategory: rewrite test_21_AcquiredPortalType

Do not depend on existing base category configuration, but create a base
category for the purpose of this test.
parent 856cd845
...@@ -751,23 +751,59 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -751,23 +751,59 @@ class TestCMFCategory(ERP5TypeTestCase):
def test_21_AcquiredPortalType(self): def test_21_AcquiredPortalType(self):
"""Test if acquired_portal_type works correctly.""" """Test if acquired_portal_type works correctly."""
self.getCategoryTool().newContent(
portal_type='Base Category',
id='test_acquired_portal_type_base_category',
acquisition_base_category_list=('order',),
acquisition_portal_type="python: ('Sale Order', )",
)
def addBaseCategoryToTypeDefinition(type_definition):
base_category_set = set(type_definition.getTypeBaseCategoryList())
base_category_set.add('test_acquired_portal_type_base_category')
type_definition.setTypeBaseCategoryList(tuple(base_category_set))
def removeBaseCategoryToTypeDefinition(type_definition):
base_category_set = set(type_definition.getTypeBaseCategoryList())
base_category_set.discard('test_acquired_portal_type_base_category')
type_definition.setTypeBaseCategoryList(tuple(base_category_set))
addBaseCategoryToTypeDefinition(self.portal.portal_types['Sale Order'])
addBaseCategoryToTypeDefinition(self.portal.portal_types['Sale Packing List'])
self.commit()
order = self.portal.sale_order_module[self.id1] try:
packing_list = self.portal.sale_packing_list_module[self.id1] order = self.portal.sale_order_module[self.id1]
person = self.getPersonModule()[self.id1] packing_list = self.portal.sale_packing_list_module[self.id1]
person = self.getPersonModule()[self.id1]
person.setTitle('toto')
self.assertEqual(person.getTitle(), 'toto') person.setTitle('toto')
order.setDestinationAdministrationValue(person) order.setTestAcquiredPortalTypeBaseCategoryValue(person)
self.assertEqual(order.getDestinationAdministrationPersonTitle(), 'toto') self.assertEqual('toto', order.getTestAcquiredPortalTypeBaseCategoryTitle())
packing_list.setDestinationAdministrationValue(None) self.assertEqual(None, packing_list.getTestAcquiredPortalTypeBaseCategoryTitle())
packing_list.setOrderValue(None)
self.assertEqual(packing_list.getDestinationAdministrationPersonTitle(), None) packing_list.setOrderValue(order)
self.assertEqual('toto', packing_list.getTestAcquiredPortalTypeBaseCategoryTitle())
packing_list.setOrderValue(order)
self.assertEqual(packing_list.getDestinationAdministrationPersonTitle(), 'toto') # category acquisition only acquire from `acquisition_base_category_list`
# if the document related through this `acquisition_base_category_list`'s
# portal type is in `acquisition_portal_type`
self.getCategoryTool().test_acquired_portal_type_base_category.setAcquisitionPortalType(
"python:('Person', 'Sale Packing List', )",) # Not Sale Order
self.commit()
self.assertEqual(None, packing_list.getTestAcquiredPortalTypeBaseCategoryTitle())
# if `acquisition_portal_type` is empty, acquisition will happen
# regardless of the portal type.
self.getCategoryTool().test_acquired_portal_type_base_category.setAcquisitionPortalType(
"python:()",)
self.commit()
self.assertEqual('toto', packing_list.getTestAcquiredPortalTypeBaseCategoryTitle())
finally:
removeBaseCategoryToTypeDefinition(self.portal.portal_types['Sale Order'])
removeBaseCategoryToTypeDefinition(self.portal.portal_types['Sale Packing List'])
self.commit()
def test_22_UserFriendlyException(self): def test_22_UserFriendlyException(self):
"""Test message raise if bad use of setter.""" """Test message raise if bad use of setter."""
......
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