Commit b097cbd4 authored by Łukasz Nowak's avatar Łukasz Nowak

- deliver helper method _testSubContentReindexing and reuse it to test various types


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36991 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 322dbb54
......@@ -87,6 +87,33 @@ class TestOrderMixin:
def unwrap_catalogObjectList(self):
Catalog.catalogObjectList = self.original_catalogObjectList
def _testSubContentReindexing(self, parent_document, children_document_list):
"""Helper method which shall be called *before* tic or commit"""
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
expected_path_list = [q.getPath() for q in children_document_list +
[parent_document]]
try:
# wrap call to catalogObjectList
self.wrap_catalogObjectList()
self.stepTic()
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
# do real assertions
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
parent_document.reindexObject()
self.stepTic()
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
finally:
# unwrap catalogObjectList
self.unwrap_catalogObjectList()
def setUpPreferences(self):
#create apparel variation preferences
portal_preferences = self.getPreferenceTool()
......@@ -2861,40 +2888,15 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
def test_subcontent_reindexing(self):
"""Tests, that modification on Order are propagated to lines and cells
during reindxation"""
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
try:
# wrap call to catalogObjectList
self.wrap_catalogObjectList()
# prepare test data
order = self.portal.getDefaultModule(self.order_portal_type).newContent(
portal_type=self.order_portal_type)
order_line = order.newContent(portal_type=self.order_line_portal_type)
inner_order_line = order.newContent(
portal_type=self.order_line_portal_type).newContent(
inner_order_line = order_line.newContent(
portal_type=self.order_line_portal_type)
order_cell = order_line.newContent(
portal_type=self.order_cell_portal_type)
expected_path_list = [order.getPath(), order_line.getPath(),
inner_order_line.getPath(), order_cell.getPath()]
self.stepTic()
# check that all would be catalogged
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
# do real assertions
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
order.reindexObject()
self.stepTic()
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
finally:
# unwrap catalogObjectList
self.unwrap_catalogObjectList()
self._testSubContentReindexing(order, [order_line, inner_order_line,
order_cell])
def test_suite():
suite = unittest.TestSuite()
......
......@@ -1576,12 +1576,6 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
def test_subcontent_reindexing_packing_list_line_cell(self):
"""Tests, that indexation of Packing List are propagated to subobjects
during reindxation"""
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
try:
# wrap call to catalogObjectList
self.wrap_catalogObjectList()
# prepare test data
packing_list = self.portal.getDefaultModule(
self.packing_list_portal_type).newContent(
portal_type=self.packing_list_portal_type)
......@@ -1589,36 +1583,12 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
portal_type=self.packing_list_line_portal_type)
packing_list_cell = packing_list_line.newContent(
portal_type=self.packing_list_cell_portal_type)
expected_path_list = [packing_list.getPath(),
packing_list_line.getPath(), packing_list_cell.getPath()]
self.stepTic()
# check that all would be catalogged
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
# do real assertions
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
packing_list.reindexObject()
self.stepTic()
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
finally:
# unwrap catalogObjectList
self.unwrap_catalogObjectList()
self._testSubContentReindexing(packing_list, [packing_list_line,
packing_list_cell])
def test_subcontent_reindexing_packing_list_container_line_cell(self):
"""Tests, that indexation of Packing List are propagated to subobjects
during reindxation, for Container, Container Line and Container Cell"""
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
try:
# wrap call to catalogObjectList
self.wrap_catalogObjectList()
# prepare test data
packing_list = self.portal.getDefaultModule(
self.packing_list_portal_type).newContent(
portal_type=self.packing_list_portal_type)
......@@ -1628,26 +1598,8 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
portal_type=self.container_line_portal_type)
container_cell = container_line.newContent(
portal_type=self.container_cell_portal_type)
expected_path_list = [packing_list.getPath(), container.getPath(),
container_line.getPath(), container_cell]
self.stepTic()
# check that all would be catalogged
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
# do real assertions
self.portal.catalogged_object_path_dict = PersistentMapping()
transaction.commit()
packing_list.reindexObject()
self.stepTic()
self.assertSameSet(
self.portal.catalogged_object_path_dict.keys(),
expected_path_list
)
finally:
# unwrap catalogObjectList
self.unwrap_catalogObjectList()
self._testSubContentReindexing(packing_list, [container, container_line,
container_cell])
class TestAutomaticSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
quiet = 0
......
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