Commit 60cb64f2 authored by Jérome Perrin's avatar Jérome Perrin

testCMFActivity: support pickle protocol > 0 in test_insert_max_payload

This test assumed that activating a method with a string of length `n+x`
as argument would be serialized in `x` more bytes that activating the
same method with a string of length `n` as argument, which is only true
for protocol 0 for multiple reasons ( short strings and long strings
are serialized differently, "frames" are used with protocol 5) and
db.string_literal seems to introduce a difference.

Change the test to mock Message.dump to produce longer dumps instead of
relying on this assumption.
parent 1caa3bed
Pipeline #34438 failed with stage
in 0 seconds
......@@ -1905,18 +1905,30 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
activity_tool.activate(activity=activity, group_id=str(i)
).doSomething(arg)
activity_tool.activate(activity=activity, group_id='~'
).doSomething(' ' * n)
).doSomething(last_message_arg)
self.tic()
self.assertEqual(len(invoke_list), N)
invoke_list.remove(n)
invoke_list.remove(len(last_message_arg))
self.assertEqual(set(invoke_list), {len(arg)})
del invoke_list[:]
activity_tool.__class__.doSomething = \
lambda self, arg: invoke_list.append(len(arg))
original_dump = Message.dump
def dump(m):
dumped = original_dump(m)
if m.args == (last_message_arg, ):
dumped += b' ' * n
return dumped
Message.dump = staticmethod(dump)
try:
DB.query = query
for activity in ActivityTool.activity_dict:
# We'll activate N-1 times with `arg`, which is a long string that
# should produce large messsage dumps and 1 time with
# `last_message_arg`, for which dump is patched to artificially
# produce a message dump `n` bytes longer than usual.
arg = ' ' * (max_allowed_packet // N)
last_message_arg = 'last'
# Find the size of the last message argument, such that all messages
# are inserted in a single query whose size is to the maximum allowed.
n = 0
......@@ -1937,6 +1949,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
finally:
del activity_tool.__class__.doSomething
DB.query = original_query
Message.dump = original_dump
def test_115_TestSerializationTagSQLDictPreventsParallelExecution(self):
"""
......
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