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: ...@@ -87,6 +87,33 @@ class TestOrderMixin:
def unwrap_catalogObjectList(self): def unwrap_catalogObjectList(self):
Catalog.catalogObjectList = self.original_catalogObjectList 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): def setUpPreferences(self):
#create apparel variation preferences #create apparel variation preferences
portal_preferences = self.getPreferenceTool() portal_preferences = self.getPreferenceTool()
...@@ -2861,40 +2888,15 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2861,40 +2888,15 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
def test_subcontent_reindexing(self): def test_subcontent_reindexing(self):
"""Tests, that modification on Order are propagated to lines and cells """Tests, that modification on Order are propagated to lines and cells
during reindxation""" during reindxation"""
self.portal.catalogged_object_path_dict = PersistentMapping() order = self.portal.getDefaultModule(self.order_portal_type).newContent(
transaction.commit() portal_type=self.order_portal_type)
try: order_line = order.newContent(portal_type=self.order_line_portal_type)
# wrap call to catalogObjectList inner_order_line = order_line.newContent(
self.wrap_catalogObjectList() portal_type=self.order_line_portal_type)
# prepare test data order_cell = order_line.newContent(
order = self.portal.getDefaultModule(self.order_portal_type).newContent( portal_type=self.order_cell_portal_type)
portal_type=self.order_portal_type) self._testSubContentReindexing(order, [order_line, inner_order_line,
order_line = order.newContent(portal_type=self.order_line_portal_type) order_cell])
inner_order_line = order.newContent(
portal_type=self.order_line_portal_type).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()
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -1576,78 +1576,30 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1576,78 +1576,30 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
def test_subcontent_reindexing_packing_list_line_cell(self): def test_subcontent_reindexing_packing_list_line_cell(self):
"""Tests, that indexation of Packing List are propagated to subobjects """Tests, that indexation of Packing List are propagated to subobjects
during reindxation""" during reindxation"""
self.portal.catalogged_object_path_dict = PersistentMapping() packing_list = self.portal.getDefaultModule(
transaction.commit() self.packing_list_portal_type).newContent(
try: portal_type=self.packing_list_portal_type)
# wrap call to catalogObjectList packing_list_line = packing_list.newContent(
self.wrap_catalogObjectList() portal_type=self.packing_list_line_portal_type)
# prepare test data packing_list_cell = packing_list_line.newContent(
packing_list = self.portal.getDefaultModule( portal_type=self.packing_list_cell_portal_type)
self.packing_list_portal_type).newContent( self._testSubContentReindexing(packing_list, [packing_list_line,
portal_type=self.packing_list_portal_type) packing_list_cell])
packing_list_line = packing_list.newContent(
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()
def test_subcontent_reindexing_packing_list_container_line_cell(self): def test_subcontent_reindexing_packing_list_container_line_cell(self):
"""Tests, that indexation of Packing List are propagated to subobjects """Tests, that indexation of Packing List are propagated to subobjects
during reindxation, for Container, Container Line and Container Cell""" during reindxation, for Container, Container Line and Container Cell"""
self.portal.catalogged_object_path_dict = PersistentMapping() packing_list = self.portal.getDefaultModule(
transaction.commit() self.packing_list_portal_type).newContent(
try: portal_type=self.packing_list_portal_type)
# wrap call to catalogObjectList container = packing_list.newContent(
self.wrap_catalogObjectList() portal_type=self.container_portal_type)
# prepare test data container_line = container.newContent(
packing_list = self.portal.getDefaultModule( portal_type=self.container_line_portal_type)
self.packing_list_portal_type).newContent( container_cell = container_line.newContent(
portal_type=self.packing_list_portal_type) portal_type=self.container_cell_portal_type)
container = packing_list.newContent( self._testSubContentReindexing(packing_list, [container, container_line,
portal_type=self.container_portal_type) container_cell])
container_line = container.newContent(
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()
class TestAutomaticSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase): class TestAutomaticSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
quiet = 0 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