Fix random test failure in testERP5WebWithCRM

Make sure Web Message events are properly reindexed after creation, before the fetch_incoming_web_message_list alarm is run
parent 552b353a
......@@ -79,9 +79,10 @@ if connected_user is not None:\n
# 1- Metadata discovery will be run by alarms with allowed user to access other documents.\n
# 2- A proxy role can not wrap portal_contributions calls and disallow Anonymous user to create the document.\n
tag = \'incoming_web_message\'\n
edit_kw[\'activate_kw\'] = {\'tag\': tag}\n
module.activate(tag=tag, activity=\'SQLQueue\').EventModule_addWebMessage(**edit_kw)\n
\n
# Trig explicitely alarm which will run discoverMetadata on created event, then \n
# Trigger explicitly the alarm which will run discoverMetadata on created event, then \n
# Fill in discoverable properties (sender, recipient, ...) and change workflow states.\n
# XXX hardcoded id, must be picked up by reference and version API\n
portal.portal_alarms.fetch_incoming_web_message_list.activate(after_tag=tag).activeSense()\n
......
1085
\ No newline at end of file
1086
\ No newline at end of file
......@@ -28,6 +28,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
......@@ -159,6 +160,34 @@ class TestERP5WebWithCRM(ERP5TypeTestCase):
'text_content': 'I want ERP5 for my company',
}
web_section.WebSection_addWebMessage(**form_kw)
transaction.commit()
# here we check a random bug caused by the ordering of activities
should_stop = [None]
event_module_path_prefix = self.portal.event_module.getPath() + '/'
deprioritize_message_list = []
# we'll stop whenever we find the message that reindex the newly created
# event object
def stop_condition(message_list):
for message in message_list:
object_path = '/'.join(message.object_path)
if (message.method_id == 'immediateReindexObject' and
object_path.startswith(event_module_path_prefix)):
deprioritize_message_list.append(message)
return True
return False
self.tic(stop_condition=stop_condition)
web_message_reindex_message, = deprioritize_message_list
web_message_path = web_message_reindex_message.object_path
self.assertTrue(
self.portal.unrestrictedTraverse(web_message_path).getPortalType(),
'Web Message',
)
# we'll deprioritize this message, so it executes last of all
self.portal.cmf_activity_sql_connection.manage_test("""
update message set priority=100
where uid=%s
""" % web_message_reindex_message.uid)
transaction.commit()
self.tic()
self.logout()
......
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