Commit 9aaa691d authored by Vincent Pelletier's avatar Vincent Pelletier

Add a unit test for reindexation's use of CMFActivity's serialization_tag.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19533 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dc0c222c
......@@ -2484,6 +2484,106 @@ VALUES
sql_catalog.sql_search_tables = current_sql_search_tables
get_transaction().commit()
def test_ObjectReindexationConcurency(self, quiet=quiet, run=run_all_test):
if not run:
return
portal = self.getPortalObject()
portal_activities = getattr(portal, 'portal_activities', None)
if portal_activities is None:
ZopeTestCase._print('\n Skipping test_ObjectReindexatoinConcurency (portal_activities not found)')
return
container = organisation_module = portal.organisation_module
document_1 = container.newContent()
document_1_1 = document_1.newContent()
document_1_2 = document_1.newContent()
document_2 = container.newContent()
get_transaction().commit()
self.tic()
# First case: parent, then child
document_1.reindexObject()
self.assertEqual(len(portal_activities.getMessageList()), 0)
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 1)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 1)
document_1_1.reindexObject()
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 2)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 1)
self.tic()
# Variation of first case: parent's borther along
document_1.reindexObject()
document_2.reindexObject()
self.assertEqual(len(portal_activities.getMessageList()), 0)
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 2)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 2)
document_1_1.reindexObject()
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 3)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 2)
self.tic()
# Second case: child, then parent
document_1_1.reindexObject()
self.assertEqual(len(portal_activities.getMessageList()), 0)
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 1)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 1)
document_1.reindexObject()
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 2)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 1)
self.tic()
# Variation of second case: parent's borther along
document_1_1.reindexObject()
document_2.reindexObject()
self.assertEqual(len(portal_activities.getMessageList()), 0)
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 2)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 2)
document_1.reindexObject()
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 3)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 2)
self.tic()
# Third case: child 1, then child 2
document_1_1.reindexObject()
self.assertEqual(len(portal_activities.getMessageList()), 0)
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 1)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 1)
document_1_2.reindexObject()
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 2)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 1)
self.tic()
# Variation of third case: parent's borther along
document_1_1.reindexObject()
document_2.reindexObject()
self.assertEqual(len(portal_activities.getMessageList()), 0)
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 2)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 2)
document_1_2.reindexObject()
get_transaction().commit()
self.assertEqual(len(portal_activities.getMessageList()), 3)
portal_activities.distribute()
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 2)
self.tic()
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Catalog))
......
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